Aniruddh Kewat

Aniruddh Kewat

  • NA
  • 30
  • 20.7k

how _doPostback works ?

Jun 14 2015 10:03 PM
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
function SaveWithParameter(parameter) {
__doPostBack('btnSave', parameter)
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnSave" runat="server" Text="click me" OnClientClick="SaveWithParameter('Hello Michael')" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br /> <br />
</form>
</body>
</html>
 
code behind
 
protected void Page_Load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
string eventtarget = Request["_EVENTTARGET"]; // parameter
string eventargument = Request["_EVENTARGUMENT"];
// Request["__EVENTTARGET"]; // btnSave
Label1.Text = "EVENTTARGET : " + eventtarget + "EVENTARGUMENT : " + eventargument;
}
}
 
 

Answers (4)