ASP.NET Textbox TextChanged and Button OnClick event interaction?

六月ゝ 毕业季﹏ 提交于 2019-12-07 22:46:53

问题


I've got an ASP.NET application that I'm accessing through Google Chrome. On a particular page I've got an asp:TextBox with a OnTextChanged event that recalculates a few other fields on the page. I've also got an asp:LinkButton with an OnClick event that saves the changes to the database.

I was facing a problem where the user left the TextBox by clicking on the save button. The button was firing before the TextChanged event so the changes were not being captured in the save. I fixed this by duplicating the TextChanged logic at the beginning of the save method. Did some testing before I committed these changes and everything was working fine.

But now my tester is facing a different problem. When he changes the text field and clicks the save button, the OnTextChanged event is firing to update the other values on the page but the OnClick event for the save button is not firing at all. He has to click the save button a second time to get the OnClick event to fire. I tested the same functionality on my machine and it's still working fine for me. He and I are looking at exactly the same page in the same environment with the same database. I had my tester clear his cache etc. The only difference I can find is that my Chrome version is "14.0.835.202 m" while his is simply "14.0.835.202".

Are there any known issues with Chrome and ASP.NET where event firing can be non-deterministic or something? Anyone have any other idea why this might be happening? Thanks for your time!


回答1:


I believe this is a known issue.

One option is to disable the button (client-side) when the user is typing in the TextBox, and enable it after the TextChanged event completes.

Another option is to remove AutoPostBack="true" and use AJAX instead.



来源:https://stackoverflow.com/questions/7842384/asp-net-textbox-textchanged-and-button-onclick-event-interaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!