I want to remove an event in code behind.
For example my control is like this.
<asp:Textbox ID="txtName" runat="server" OnTextChanged="txtName_Changed" AutoPostBack="true" />
I want to remove the OnTextChanged
programmatically.. how can I achieve this?
Add("style","display:none"); div_id: id which you want to hide. Attributes: that will use value. Add: keyword will add the attribute.
In C#, you can add and remove event handlers quite easily from the code-behind:
// Add event handler:
txtName.OnTextChanged += new EventHandler(txtName_Changed);
// Remove event handler:
txtName.OnTextChanged -= new EventHandler(txtName_Changed);
In VB.NET code:
RemoveHandler txtName.OnTextChanged, addressof txtName_Changed
Or in C#:
http://www.devnewsgroups.net/dotnetframework/t16784-remove-event-handlers-net.aspx
obj.Click += new EventHandler(BeAlert); // register an event handler
obj.Click -= new EventHandler(BeAlert); // unregister the same event handler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With