相關問題: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'屬性。 –