📄 templatereplace.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Template
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Web.UI;
using System;
using System.IO;
using System.Web.UI.WebControls;
public class TemplateReplace : AdminPage
{
protected Button BtnBack;
protected Button BtnReplace;
protected DropDownList DropReplaceFile;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtNewContent;
protected TextBox TxtOriginalContent;
protected PowerEasy.Controls.RequiredFieldValidator ValrOriginalContent;
protected void BtnBack_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("TemplateManage.aspx?Dir=" + base.Server.UrlEncode(BasePage.RequestString("Dir")));
}
protected void BtnReplace_Click(object sender, EventArgs e)
{
string text = this.TxtOriginalContent.Text;
string newContent = this.TxtNewContent.Text;
string selectedValue = this.DropReplaceFile.SelectedValue;
FileSystemObject.ReplaceFileContent(base.Request.PhysicalApplicationPath + (SiteConfig.SiteOption.TemplateDir + selectedValue + "/"), text, newContent);
AdminPage.WriteSuccessMsg("在" + selectedValue + "目录范围内的模板文件,将文件内容中的“" + text + "”批量替换成 “" + newContent + "”执行完毕!", "TemplateManage.aspx?Dir=" + base.Server.UrlEncode(BasePage.RequestString("Dir")));
}
private void DrpFilePath(ListControl dropName)
{
string templateDir = SiteConfig.SiteOption.TemplateDir;
if (!string.IsNullOrEmpty(templateDir))
{
DirectoryInfo info = new DirectoryInfo(base.Request.PhysicalApplicationPath + templateDir);
if (info.Exists)
{
foreach (DirectoryInfo info2 in info.GetDirectories("*", SearchOption.AllDirectories))
{
if (!info2.FullName.Contains("标签库") && !info2.FullName.Contains("分页标签库"))
{
string text = (info2.FullName.Remove(0, info.FullName.Length) + "/").Replace(@"\", "/");
dropName.Items.Add(new ListItem(text, text));
}
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
this.DrpFilePath(this.DropReplaceFile);
string str = BasePage.RequestString("Dir");
if (!string.IsNullOrEmpty(str))
{
this.DropReplaceFile.SelectedValue = str + "/";
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -