ASP.Net button click event not firing

2019-02-14 08:33发布

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.

7条回答
做自己的国王
2楼-- · 2019-02-14 09:01

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.

查看更多
Melony?
3楼-- · 2019-02-14 09:02

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....

查看更多
爷、活的狠高调
4楼-- · 2019-02-14 09:03

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

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-02-14 09:06

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.

查看更多
三岁会撩人
6楼-- · 2019-02-14 09:11

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

查看更多
做个烂人
7楼-- · 2019-02-14 09:11

have you tried:

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

查看更多
登录 后发表回答