__doPostBack method in Javascript

Akiii
Posted by Akiii under JavaScript category on | Points: 40 | Views : 3783
__doPostBack() function is used to make server side event call. For example, If you want to call a server side button click from Javascript then you can use __doPostBack() function. it has two arguments eventTarget and eventArgument.

eventTarget == ID of the control for the post back 
eventArgument == additional data associated with the control.


<input id="btnSave" type="button" onclick="javascript:Save('Hello World')" value="click me"/>


<script type="text/javascript">
function Save(parameter)
{
__doPostBack('btnSave ', parameter)
}
</script>



And in your code behind add something like this to read the value and operate upon it:
public void Page_Load(object sender, EventArgs e)
{
string parameter = Request["__EVENTARGUMENT"];
}




Thanks and Regards
Akiii

Comments or Responses

Login to post response