Removing an event handler from your code
I have an asp.net dropdown like this
<asp:DropDownList ID="ddLevel" runat="server" Width="95%" AutoPostBack="True" OnSelectedIndexChanged="ddYear_SelectedIndexChanged">
In some conditions, I am trying to remove the handler for the OnSelectedIndexChanged event. I tried
ddLevel.SelectedIndexChanged -=ddYear_SelectedIndexChanged;
It didn't work. Then I tried
ddLevel.SelectedIndexChanged -=new EventHandler(ddYear_SelectedIndexChanged);
But both of them don't work. When I check the page source, I still see the exchange event.
I have checked these two links link1 and link2 . I don't understand what I am doing wrong. I would like to knwo if there is another way to do this. Is the reason for this that I am doing this in an event Page_Load
?
+3
source to share