admin管理员组文章数量:1402059
I have a control that is basically functioning as a client-side timer countdown control.
I want to fire a server-side event when the count down has reached a certain time.
Does anyone have an idea how this could be done?
So, when timer counts down to 0, a server-side event is fired.
I have a control that is basically functioning as a client-side timer countdown control.
I want to fire a server-side event when the count down has reached a certain time.
Does anyone have an idea how this could be done?
So, when timer counts down to 0, a server-side event is fired.
Share Improve this question asked Nov 5, 2008 at 16:46 Brian LiangBrian Liang 7,77410 gold badges60 silver badges72 bronze badges4 Answers
Reset to default 3You would probably want to use AJAX to make your server side call.
IIRC, there is a timer server control that should do this for you.
When you render the page create a client-side button that would do the action you want on postback. Then use ClientScriptManager.GetPostBackEventReference passing in the control as reference and add a client-side event to it using attributes as the example at the bottom of that link shows.
You can then see the Javascript it renders and use that in your function to trigger the correct server-side event.
Below is one way to notify the server of an event. You are really firing a client side event but then municating with the server. This is if you aren't living in an AJAX world though.
function NotifyServer()
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange = OnNotifyServerComplete;
xmlHttp.open("GET", "serverpage.aspx", true);
xmlHttp.send();
}
function OnNotifyServerComplete()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
if (xmlHttp.responseText != "1")
//do something
}
}
}
本文标签: netHow do you raise a serverside event from javascriptStack Overflow
版权声明:本文标题:.net - How do you raise a server-side event from javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744343661a2601627.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论