https://blog.csdn.net/weixin_35607038?spm=1008.2028.3001.5343\
关于WebForm_DoPostBackWithOptions渲染的js方法的Linkbuton方法失效问题
问题:如题, 原因:aspnet 的webform页面中存在验证控件,对linkbutton的js渲染的方法,自动的将 javascript:__doPostBack 升级为:javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(… 从而导致js的方法失效。 解决方法:linkbutton添加属性:CauseValidation=False
具体分析,下面这个文章已经将的很详细了,不再赘述。
WebForm_DoPostBackWithOptions vs __doPostback(转载)
had an issue with WebForm_DoPostBackWithOptions vs __doPostback. WebForm_DoPostBackWithOptions started showing up on a page and not showing up on other .NET pages. It was a pain in my butt! Because WebForm_DoPostBackWithOptions wasn’t working, all my linkbutton had this javascript function rendered and none of the events were firing! So after looking around I found out that I had some panels that were hidden on the page. And in one of those panels, I have a validation control, if a validation control is “hidden” on the page (the panel’s visibility is set to false and later made visible) then .NET adds WebForm_DoPostBackWithOptions to the button controls and thus does not work. To fix this I had to change the linkbuttons that were not hidden to cause validation to false. (CauseValidation=False). Once I did that, it work! What a pain in the butt!
|