Skip navigation

A .Net page can be posted back with JavaScript. We can call __doPostBack() function to generate a manual postback.

The following example shows how to do the postback manually with JavaScript and detect the manual postback from server side. In our example, we will call “PerformTask()” server side method on postback. The __doPostBack() function takes two parameters — eventTarget and eventArgument.

JavaScript:

__doPostBack(‘__Page’, ‘performTask’);

Server side:

protected void Page_Load(object sender, System.EventArgs e)

{

if(Page.IsPostBack)

{

if(Request[“__EVENTARGUMENT”] == “performTask”)

{

PerformTask();

}

}

}

private void PerformTask()

{

//perform the processing after manual postback

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: