小记
public static void PageExcecScript(System.Web.UI.Page currentPage, string strstr)
{
//脚本块的内容
//先将提示信息中的某些字符做转换,否则会影响脚本的执行
string strDescription = "";
strDescription = strstr.Replace("\"", "\\\"");
strDescription = strstr.Replace("\\", "\\\\");
strDescription = strstr.Replace("\r", "\\r");
strDescription = strstr.Replace("\n", "\\n");
string csname = Guid.NewGuid().ToString();//随机定义脚本块名称
ClientScriptManager cs = currentPage.ClientScript;
if (!cs.IsStartupScriptRegistered(currentPage.GetType(), csname))
{
string cstext = strDescription;
cs.RegisterStartupScript(currentPage.GetType(), csname, cstext, true);
}
}
**************************************************
string JStr = "document.getElementById('txt_AreaCityName').disabled='true';document.getElementById('txt_AreaCityName').style.background='Silver';";
CommonHelper.PageExcecScript(this.Page, JStr);
**********************************************
this.txt_AreaCityName.Style.Add("background-color", "Silver");
this.txt_AreaCityName.Attributes.CssStyle.Add("background-color", "Silver");
this.txt_AreaCityName.Attributes.Add("style", "");
******************************************************************