Relegence
asked on
Calling a javascript function from server side, using AJAX timer
Hello,
I am developing a ASP.NET ajax application.
I am using a timer:
<asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick" Interval="5000" />
The only thing I want to do is to call a javascript function on every tick of the timer:
protected void Timer_Tick(object sender, EventArgs e)
{
ClientScript.RegisterClien tScriptBlo ck(this.Ge tType(), "blink", "<script>blinkit('2');</sc ript>");
}
This doesn't work.
The javascript function is being called only if I put the 'RegisterClientScriptBlock ' in the Page_Load.
How can I call the javascript every couple of seconds?
Thank you
I am developing a ASP.NET ajax application.
I am using a timer:
<asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick" Interval="5000" />
The only thing I want to do is to call a javascript function on every tick of the timer:
protected void Timer_Tick(object sender, EventArgs e)
{
ClientScript.RegisterClien
}
This doesn't work.
The javascript function is being called only if I put the 'RegisterClientScriptBlock
How can I call the javascript every couple of seconds?
Thank you
ASKER
I am afraid it didn't help.
Below is my code
Below is my code
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick" Interval="5000" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label ID="lbl" runat="server"></asp:Label>
<label id="lblHTML">test</label>
</div>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot. it works perfectly!!
Don't know about the rest of your code but if you try using:
protected void Timer_Tick(object sender, EventArgs e)
{
ClientScript.RegisterStart
}
it should work depending if you are making a full postback or not (which is needed for this way to work). If You are controlling the contents of an update panel with the timer I guess you need to add the timer as a postback trigger (not async) for the update panel.
/Carl.