晕,Microsoft搞什么鬼,自定义控件问题。。。
我重写CreateChildControls()函数,在该函数里面实力化一个TextBox控件,然后在javascript里面处理,而CreateChildControls()重写后子控件命名规律是Webcontrol1:_ctl1,该命名正好是js不认的,也就是在js里面会出错,my god。。。,那位高手能帮下忙????
protected override void CreateChildControls()
{
base.Controls.Clear();
System.Web.UI.WebControls.TextBox txt=new System.Web.UI.WebControls.TextBox();
//txt.Visible=false;
txt.ClientID=txt.ClientID.ToString();
this.Controls.Add(txt);
//Controls.Add(new LiteralControl(str_Js.Replace("{0}",txt.UniqueID.ToString()))); // html[0]
string str_S=str_Js;
if (this.Text!=null)
{
str_S=str_S+"<script>sel = idEdit.document.selection.createRange();sel.pasteHTML(document.forms(0)."+txt.ClientID.ToString()+".value);</script>"; // js脚板
}
Controls.Add(new LiteralControl(str_S.Replace("{0}",txt.UniqueID.ToString()))); // html[0]
}