Calling ASP.NET server side subroutine from javascript

  • Thread starter Thread starter asadikhan
  • Start date Start date
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
 
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.
 
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])
 
Back
Top