Calling ASP.NET server side subroutine from javascript

A

asadikhan

Hi, I have a timer in javascript on my ASP.NET page. When the time
expires (a point in my javascript code) I want to call a subroutine
in my ASP.NET page. But I can't seem to figure out how to do this.

My subroutine is actually a function I call as a result of a button
click. But if the user doesn't click the button in the allotted time,
I want to go ahead and call the function anyways.

Any idea how I can do this?

Thanks.

Asad
 
B

Bonj

use the __doPostBack('MyButton', '') javascript function. MyButton is, say,
an <asp:linkbutton> (definitely works) but I think it can be anything.
If you look at the html source generated when you run an aspx page you will
find that this is what asp.net server controls do anyway.
You can use
document.forms['Form1'].item('postbackparams').value = arg
where postbackparams is, say, an <input type="hidden" id="postbackparams">
to set parameters.
 
G

Guest

Hi

A simple approach can be to 'refresh' the page when its 'TimeOut' - specify yo Time-Out period in the parameter 'Refresh' of the meta content on top of the page and set its 'content' to say 5 (5 seconds) - this will refresh yo page every 5 seconds ..

Now on the server side all yo've to do is check fo yo condition(i.e a value in text-box) in 'Page_Load' and call event if its true !!

Tell me if this doesn't work ([email protected])
 

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,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top