現我要將原html服務器控件TextArea中加入雙擊事件,我改改了原控件,但輸出的html控件都怎麼也沒有雙擊事件,哪裡有問題?using System;namespace UserControls
{ public class TEXTAREA : System.Web.UI.HtmlControls.HtmlTextArea
{
public TEXTAREA(){} protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
System.Web.UI.AttributeCollection attrColl = this.Attributes;
if(attrColl["ondblclick"]==null || attrColl["ondblclick"]=="")
{
System.Web.HttpContext cur = System.Web.HttpContext.Current;
string sPath = cur.Request.ApplicationPath + "/char.htm";
string strFeatures = "dialogWidth=198px;dialogHeight=142px;center=yes;help=no";
//string script = "this.value = this.value + window.showModalDialog('" + sPath + "','new','" + strFeatures + "');";
string script = " var strRC = window.showModalDialog('" + sPath + "','new','" + strFeatures + "');" ;
script += " if(strRC == null ) { strRC = ''; } this.value += strRC ;" ;
writer.AddAttribute("ondblclick",script);
}
base.Render (writer);
} }
}