__doPostBack method in Javascript

Posted by Akiii under JavaScript category on | Points: 40 | Views : 2663
__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)

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

Comments or Responses

Login to post response