hi every one.
i am using java script to call setTimeout() function
and i want to call myfunction () inside setTimeout()
setTimeout(myfunction(); time)
but the myfuction() is written in Codebehind
please i want to know if i can do that if it is possible, how i can do that
This might work:
setTimeout("timedFunction()", time)function timedFunction()
{
__doPostBack('TimerFunction', '');
}// CodeBehind Page_Load event handler
private void Page_Load(object sender, System.EventArgs e)
{
// Insure that the JavaScript __doPostBack method is added...
this.GetPostBackEventReference(this, "PBArg");if ( this.IsPostBack )
{
object eventTarget = this.Request["__EVENTTARGET"];if ( (eventTarget != null) &&
(eventTarget.ToString() == "TimerFunction") )
{
// Call your CodeBehind method
myfunction();
}
}
}
NC...
JavaScript and the server are two seperate things that can not talk like that. You can use the __doPostBack(eventTarget, eventArgument) to trigger a post back to the server so you can execute that code on the server.
Eric
Pascarello.com | Twitter epascarello | LinkedIn
Mr NC01 thank you very much for helping
i tried your code , it is working
I hope I can get help for something as follows:
A method in a form pop up a window in javascript to prompt for user input. Basically the code is Response.Write("open.window..."). The window opens another webform that does some data processing thru the user prompt then closes itself with Response.Write(" window.close();"). At this point will the focus land back to the calling form and the remaining code in its method continue to execute? Upon testing my code, I have the impression that the whole thing hangs there and nothing else happens. Can someone give me some light on that? Thanks much.
Please mark the post(s) that have helped you as "Answer"