它是确定使用__doPostBack()? [英] Is it OK to use __doPostBack()?

查看:124
本文介绍了它是确定使用__doPostBack()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它是确定使用 __ doPostBack()或不推荐,因为它是由ASP.Net生成的,我们不知道,如果他们在下一个版本改变了它的ASP.Net。

Is it OK to use __doPostBack() or it is not recommended because it is generated from ASP.Net and we are not sure if they changed it in a next version of ASP.Net.

推荐答案

我会建议反对它,因为它是 ASP.NET 内部的东西,从来就不是被直接使用。

I would advice against it, since it's internal stuff of ASP.NET and was never meant to be used directly.

相反,我在做什么,当我需要手动触发回发是增加隐藏服务器端按钮,用正确的OnClick:

Instead, what I'm doing when I need to "manually" trigger PostBack is adding hidden "server side" button with the proper OnClick:

<asp:Button id="btnDummy" runat="server" OnClick="Foo" style="display: none;" />

那么JS是:

document.getElementById("<%=btnDummy.ClientID%>").click();

这样,我不在乎如何回来后会发生,我只是触发事件的自然流动。

This way I don't care how post back happens, I just trigger the natural flow of events.

这篇关于它是确定使用__doPostBack()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆