相关问题:Adding custom OnTextChange event handler on custom TextBox曝光,然后用OnTextChange事件处理
在相关问题,我问我怎么能在我的自定义文本框控件暴露OnTextChange我们通过解决它:
public event EventHandler TextChanged
{
add { customTextBox.TextChanged += value; }
remove { customTextBox.TextChanged -= value; }
}
我想使用TextChanged事件这样当控制实现:
<uc:CustomTextBox ID="customTextBox"
runat="server"
OnTextChanged="CustomTextBox_OnTextChanged">
</uc:CustomTextBox>
这似乎从来没有运行的时候打以下几点:
protected void CustomTextBox_OnTextChanged(System.EventArgs e)
{
// Do something here
}
或撞击:
protected void CustomTextBox_OnTextChanged(object sender, EventArgs e)
{
// Do something here
}
什么我做错了,我错过了,这是最好的方法或惯例的方式做,我想在这里做的一切吗?
我做了以下内容:'公共虚拟BOOL的AutoPostBack {获得;组; }'然后我把'AutoPostBack ='true''这行加到了控件上,我仍然没有成功。 – Anicho
对不起队友感谢尝试,但它似乎并没有工作。第一个冒泡,然后设置为true时不起作用。覆盖返回'基地没有AutopostBack.' – Anicho
这是用户控件还是自定义服务器控件?如果它是用户控件,则在用户控件中创建一个'AutoPostBack'属性,并使用该属性来获取和设置'customTextBox.AutoPostBack'属性。 –