ASP.Net button click event not firing

2019-02-14 08:53发布

问题:

This is perhaps related to this question, but I have slightly more information.

I recently updated an ASP.Net application to .NET 3.5 after coding a few new pieces with Linq. Now my pages intermittently stop firing event handlers. I have it narrowed down to pages with Ajax on them, and I assume it's either the ScriptManager or the AjaxControlToolkit registration that is precipitating the problem.

The really screwy part is that pages seem to work fine about 2/3s of the time, and the controls lose their event handlers only 1/3 of the time. I wondered about some type of error occurring and the page not rendering correctly, but I cannot find evidence of this.

回答1:

We were have exactly this issue and as you have said it was only happening some of the time and only on pages with Ajax requests. We found that disabling the HTTP Keep-Alive as suggested in the answer to Why does Internet Explorer not send HTTP post body on Ajax call after failure? worked.

This can be done in IIS7 by following the instructions in How to configure HTTP KEEP-ALIVE in IIS 7



回答2:

i have only used Telerik Ajax controls so far, and my observation is if an exception occours in a Ajax enabled control, nothing happens. No exception report, no action. nothing.

Maybe you should test you app without ajax to identify any problem spots



回答3:

My initial thought would be that something is happening where the javascript is erroring out (un-caught) and aborting the async postback.

If you can get this to happen in a development environment, you might want to try error handling the window.onerror event and throwing some alert boxes up. It might help to see where possible errors occur.



回答4:

have you tried:

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(yourButton);



回答5:

It's seem to me, you have issue with Update Panel.

Define the following properties of Update Panel if you are using more than one update panel and updation of one panel change the data of other update panel.

For the UpdatePanel

  1. ChildrenAsTriggers = true
  2. EnableViewState = true (if you are using this feature)
  3. UpdateMode = Always

Use the same properties for other update panel in your same page.

If you find it useful, please mark it as your answer else let me know....



回答6:

Try commenting out Update panel if any. Then try to click button there must be some error on the page. I've also faced similar issues.



回答7:

In my case none of the events (either button or check box) were firing. I was able to overcome by this problem using following way.

In my master page I had closed a tag referring to an external .js file with /> notation instead of <script></script>.

for Ex: chanage <script src='../../Scripts/common/menu.Js' type='text/javascript' /> to <script src='../../Scripts/common/menu.Js' type='text/javascript' ></script>

Hope this will help you, Ramesh