How to trigger a postback from javascript

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
 
J

John Oakes

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
 
T

Teemu Keiski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top