B
Borr
Hi,
I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :
function OnPageLoad()
{
setTimeout("OnTimer()", 10000);
}
function OnTimer()
{
ServerMethod();
}
<body onload="OnPageLoad()">
<form id="Form1" method="post" runat="server">
It does not work, and I understand why - client side does
not know what is ServerMethod();
How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=server", defined such
server-side event handler for click :
void DummyBtn_ServerClick(object obj,EventArgs e)
{
ServerMethod();
}
and on the client side in OnTimer method wrote
Form1.DummyBtn.click();
So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.
It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?
I have an ASP .NET page, that runs client side timer that
does something on the Server side and after that loads
another page. So I have on client side something like :
function OnPageLoad()
{
setTimeout("OnTimer()", 10000);
}
function OnTimer()
{
ServerMethod();
}
<body onload="OnPageLoad()">
<form id="Form1" method="post" runat="server">
It does not work, and I understand why - client side does
not know what is ServerMethod();
How to call server side method from the timer callback ?
Meanwhile I found workaround : created in Form1 tiny
disabled button DummyBtn "runat=server", defined such
server-side event handler for click :
void DummyBtn_ServerClick(object obj,EventArgs e)
{
ServerMethod();
}
and on the client side in OnTimer method wrote
Form1.DummyBtn.click();
So the timer simulates click of DummyBtn, click runs its
event handler, the event handler in turn calls the server
method.
It works, but it is ugly solution. I 'd like to call
ServerMethod() from the timer callback directly, without
tricks like this. Is it possible ?