How to trigger a postback from javascript

  • Thread starter Thread starter NWx
  • Start date Start date
N

NWx

Hi,

How can I make a page to postback automatically, using JavaScript?
I need a JavaScript function as handled to page_load, but I don't know what
code to write to trigger postback.

Can anyone help me?
Regards
 
Call the __doPostBack function that ASP.NET creates:
__doPostBack(id,'');

If you want to see an example of this check out the Time Tracker starter
kit on www.asp.net. They do this to force a postback after selecting a date
from a popup calendar.

-John
 
Hi,

if you want to cause the postback as if happening in behalf of another
control (means this controls postback event is raised as well), you can use
Page.GetPostBackEventReference to return the __doPostBack call (it returns
it as string and you need to place that on page to be called)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

Hi,

How can I make a page to postback automatically, using JavaScript?
I need a JavaScript function as handled to page_load, but I don't know what
code to write to trigger postback.

Can anyone help me?
Regards
 
Back
Top