ozkank
ozkank

Reputation: 1462

Autopostback a page in Page_Unload

I want to autopost a page in Page_Unload. When I write Response.Redirect, I got error.

Want to achieve show Data List. I'm databinding it, but it shows after refreshing the page.

Can somebody help me?

protected void Page_Unload(object sender, EventArgs e)
{
  ... 
  DataList1.DataBind();
 //autopostback in this line
}

Upvotes: 0

Views: 230

Answers (2)

Thair
Thair

Reputation: 171

use the PreRender event instead of UnLoad. Note: I know its old question but I believe some one would get use of this answer.

Upvotes: 0

Guffa
Guffa

Reputation: 700212

You can't do anything like that in the Unload event.

Whe the Unload event happens, the page has already been rendered and sent to the browser, so it's too late to do anything to change the response.

Besides, making a postback from server code doesn't make sense, as that would simply create an eternal loop without anything ever being sent back to the browser. If you want to make a postback when something happens in the browser, you would do that using Javascript, not in the server code.

Upvotes: 1

Related Questions