//自定义控件 mytextbox 用于onblur触发
namespace mytextbox
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")]
public class mytextbox : System.Web.UI.WebControls.TextBox, System.Web.UI.IPostBackEventHandler
{
[Bindable(true, BindingDirection.TwoWay)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
Attributes["Onblur"] = Page.GetPostBackEventReference(this);
base.Render(writer);
} public event EventHandler Onblur;
public virtual void RaisePostBackEvent(string eventargument)
{
if (Onblur != null)
{
Onblur(this, null);
} }
}
}在使用时, <cc1:mytextbox ID="TextBox1" runat="server" Width="60px" AutoPostBack="True" Text='<%#Eval("xxx") %>' OnOnblur="TextBox1_TextChanged"></cc1:mytextbox>出错
错误 类型“mytextbox.mytextbox”中不存在类型名称“mytextbox”
去掉Text(标红部分)属性,则正常调试!请高手指点对于自定义控件,还是不太懂!
namespace mytextbox
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")]
public class mytextbox : System.Web.UI.WebControls.TextBox, System.Web.UI.IPostBackEventHandler
{
[Bindable(true, BindingDirection.TwoWay)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
Attributes["Onblur"] = Page.GetPostBackEventReference(this);
base.Render(writer);
} public event EventHandler Onblur;
public virtual void RaisePostBackEvent(string eventargument)
{
if (Onblur != null)
{
Onblur(this, null);
} }
}
}在使用时, <cc1:mytextbox ID="TextBox1" runat="server" Width="60px" AutoPostBack="True" Text='<%#Eval("xxx") %>' OnOnblur="TextBox1_TextChanged"></cc1:mytextbox>出错
错误 类型“mytextbox.mytextbox”中不存在类型名称“mytextbox”
去掉Text(标红部分)属性,则正常调试!请高手指点对于自定义控件,还是不太懂!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货