📄 cpctextbox.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Zeroone.Custom.CustomPropertyControl;
using System.Xml;
using Zeroone;
public partial class Admin_SettingCustomPropertyControl_CPCTextBox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//下拉列表列出文本模式
this.ddlTextMode.DataSource = Enum.GetNames(typeof(TextBoxMode));
this.ddlTextMode.DataBind();
//加载页面各控件
CustomPropertyControlInfo cpci = CustomPropertyControlController.GetCustomPropertyControl(Request.QueryString["path"], int.Parse(Request.QueryString["CustomPropertyID"]));
if (cpci != null)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(cpci.ControlXMLData);
XmlNode root = xmlDoc.SelectSingleNode("CustomPropertyControl");
XmlNode panelNode = root.FirstChild;
XmlNode xnTextBox = panelNode.ChildNodes[1];
//文本框前的提示
this.tbToolTip.Text = panelNode.ChildNodes[0].Attributes["text"].Value;
//文本框的各属性值
this.tbColumns.Text = xnTextBox.Attributes["columns"].Value;
this.tbMaxLength.Text = xnTextBox.Attributes["maxLength"].Value;
this.tbRows.Text = xnTextBox.Attributes["rows"].Value;
this.ddlTextMode.SelectedValue = xnTextBox.Attributes["textMode"].Value;
//启用删除
this.btnDelete.Enabled = true;
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement xe1 = xmlDoc.CreateElement("CustomPropertyControl");//创建一个<CustomPropertyControl>节点
xe1.SetAttribute("controlName", "TextBox");//设置该节点controlType属性
xmlDoc.AppendChild(xe1);
//add panel
XmlNode root = xmlDoc.SelectSingleNode("CustomPropertyControl");//查找<CustomPropertyControl>
XmlElement xePanel = xmlDoc.CreateElement("Panel");//创建一个<Item>节点
//xePanel.SetAttribute("id", Request.QueryString["CustomPropertyID"]);//设置该节点id属性
//add Literal
XmlElement xeLiteral = xmlDoc.CreateElement("Literal");
xeLiteral.SetAttribute("text",this.tbToolTip.Text);
xePanel.AppendChild(xeLiteral);
//add textbox
XmlElement xeTextBox = xmlDoc.CreateElement("TextBox");
xeTextBox.SetAttribute("columns", this.tbColumns.Text);
xeTextBox.SetAttribute("maxLength", this.tbMaxLength.Text);
xeTextBox.SetAttribute("rows", this.tbRows.Text);
xeTextBox.SetAttribute("textMode", this.ddlTextMode.SelectedValue);
xePanel.AppendChild(xeTextBox);
root.AppendChild(xePanel);
xmlDoc.AppendChild(root);//添加到<CustomPropertyControl>节点中
//保存到数据库
CustomPropertyControlInfo cpci = CustomPropertyControlController.GetCustomPropertyControl(Request.QueryString["path"], int.Parse(Request.QueryString["CustomPropertyID"]));
if (cpci != null)
{
cpci.ControlXMLData = xmlDoc.OuterXml;
CustomPropertyControlController.UpdateCustomPropertyControl(cpci);
}
else
{
cpci = new CustomPropertyControlInfo();
cpci.CustomPropertyID = int.Parse(Request.QueryString["CustomPropertyID"]);
cpci.Path = Request.QueryString["path"];
cpci.ControlXMLData = xmlDoc.OuterXml;
CustomPropertyControlController.CreateCustomPropertyControl(cpci);
}
Response.Redirect(Globals.ApplicationPath + "/admin" + Request.QueryString["path"] + "DocumentCustomProperties.aspx");
}
protected void btnDelete_Click(object sender, EventArgs e)
{
CustomPropertyControlInfo cpci = CustomPropertyControlController.GetCustomPropertyControl(Request.QueryString["path"], int.Parse(Request.QueryString["CustomPropertyID"]));
CustomPropertyControlController.DeleteCustomPropertyControl(cpci);
Response.Redirect(Globals.ApplicationPath + "/admin" + Request.QueryString["path"] + "DocumentCustomProperties.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -