ASP. NET page button click event invalidation solution

  • 2020-12-07 04:00:45
  • OfStack

Today, when I ran the previous project again, I found that the button click event did not work, and after I added the breakpoint, I found that the event was not triggered at all...

According to the answer that finds on the net, some say to delete control to drag afresh 1 go in, although also met before control invalids, drag afresh effective time, but did not work this time.

Then, moving on to the answer, some say it could be form nesting, but looking at the source code doesn't have this problem.

Accidentally, trying to add a client click event to the button:
 
OnClientClick="return true" 

It worked:
 
<asp:ImageButton ID="imgSearch" runat="server" 
ImageUrl="~/images/iconSearch.png" OnClientClick="return true" onclick="imgSearch_Click" style="margin-top:5px;" /> 

I don't know exactly why, but I'm glad it worked.

Related articles: