有的时候想在客户端触发服务器端控件的click事件
我们这么写__doPostBack('id','')
但是为什么有的时候会实效?
因为__doPostBack()函数并没有在页面产生
(如果没有类似linkbutton等控件的话asp.net引擎不产生这段js)
解决方法如下:
比如前台页面 <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
(1)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442979.jpg)
(2)
利用GetPostBackEventReference给客户端生成__doPostBack()
前台
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442979.jpg)
后台
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442979.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020448331.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020441608.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442973.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020443482.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020449058.jpg)
把Button1的按钮事件这么写:
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442979.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020448331.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020441608.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442973.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020443482.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020449058.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442979.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020448331.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020441608.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020442973.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020443482.jpg)
![](http://file.wbgxw.com/UpLoad\20100705\Re_201007051020449058.jpg)