日期:2014-05-18  浏览次数:20451 次

__doPostBack到底是干什么用的啊 谁能举一个经典的例子出来啊 谢谢
__doPostBack到底是干什么用的啊   谁能举一个经典的例子出来啊  

小弟非常感谢

------解决方案--------------------
提交页面.就是相当于asp的form.submit();只不过加了些参数
------解决方案--------------------
<form id= "form1 " runat= "server ">
<div>
<br />
<input type= "button " onclick= "javascript:__doPostBack( 'Button1 ', 'haha ') " style= "width: 245px " />
<br />
<asp:Button ID= "Button1 " runat= "server " Text= "Button " OnClick= "Button1_Click " Height= "10px " Width= "10px " />
<asp:LinkButton ID= "LinkButton1 " runat= "server "> </asp:LinkButton> </div>
</form>

protected void Button1_Click ( object sender , EventArgs e )
{
//__EVENTTARGET
string tag = ( Request[ "__EVENTTARGET "] == null ) ? " " : Convert.ToString( Request[ "__EVENTTARGET "] );
//__EVENTARGUMENT
string arg = ( Request[ "__EVENTARGUMENT "] == null ) ? " " : Convert.ToString( Request[ "__EVENTARGUMENT "] );
Response.Write( " <br/> " + tag + " <br/> " + arg );
}
------解决方案--------------------
你注意只要你的页面加了LinkButton,其客户端脚本就会有__doPostBack函数

这个时候,你可以用 __doPostBack( "服务器控件名 ", " ")来提交页面并调用其服务器端方法