📄 templateedit.ascx.cs
字号:
namespace Seaskyer.WebApp.skyNews.Pages.AdminMSC
{
using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Seaskyer.Strings;
using Seaskyer.FSO;
using Seaskyer.WebApp.skyNews.Custom;
/// <summary>
/// TemplateEdit 的摘要说明。
/// </summary>
public class TemplateEdit : basePage
{
protected TextBox Body;
protected Label label1 ;
protected System.Web.UI.WebControls.Label labelPath;
protected Button Submit;
private void Page_Load(object sender, System.EventArgs e)
{
// 加载修改模板文件内容
if( !user.IsAdmin )
{
base.strError.Add("您无权执行 “" + lang.AppName + "” 操作,详情请与管理员联系!");
return;
}
this.TempDataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
#region 响应修改事件
protected void Submit_OnClick(object sender, EventArgs e)
{
string filePath = Server.MapPath( labelPath.Text );
try
{
FObject.WriteFile(filePath, Body.Text);
user.MessageShow("操作成功", "location.href='" + basePath + "Admin/TemplateAdmin.aspx';");
}
catch
{
label1.Text = "操作失败"; label1.ForeColor = Color.Red;
}
label1.Visible = true;
}
#endregion
#region 绑定数据
void TempDataBind()
{
string id = Request.QueryString["templateID"];
TemplateInfo ti = new TemplateInfo(mp);
DataTable dt = ti.TemplateDataRow(id);
if( dt.Rows.Count == 1 )
{
string filePath = Server.MapPath( dt.Rows[0]["Path"].ToString());
labelPath.Text = dt.Rows[0]["Path"].ToString();
if ( FObject.IsExist(filePath, FsoMethod.File))
{
Body.Text = FObject.ReadFile(filePath);
}
else
{
Submit.Text = " 创 建 ";
label1.Text = "您要找的模板文件不存在"; label1.ForeColor = Color.Red;
label1.Visible = true;
}
}
else
{
label1.Text = "您要找的模板文件不存在"; label1.ForeColor = Color.Red;
label1.Visible = true;
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -