Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script controls may not be registered before PreRender. when using timer control

I'm a newbie to ASP.net (vb), and i'm working with the timer controls. I've once again researched the answer to this and done as said (overloading prerender method). My problem is I have a master page which i've added a timer control, in order to update a count down field, on going to the sites index page i keep getting the error : "Script controls may not be registered before PreRender." The timer works well on other pages except the index page.

<form id="fMain" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Timer ID="timer1" runat="server" Interval="1000" OnTick="timer1_tick"></asp:Timer></div>
     <div>
 <asp:UpdatePanel id="updPnl" runat="server" UpdateMode="Conditional">
     <ContentTemplate>
      <asp:Literal ID="litTimer" runat="server"></asp:Literal>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="timer1" EventName ="tick" />
                         </Triggers>
                    </asp:UpdatePanel>
                </div>

The Codebehind:

Sub timer1_tick() Handles timer1.Tick
       ltr1.text = "test"

End Sub`

Thank you in advance.

like image 528
user3741895 Avatar asked Oct 22 '25 00:10

user3741895


1 Answers

This is because you are using Telerik controls and have overridden the OnPreRender method.

You need to add the following to this method:

protected override void OnPreRender(EventArgs e)  
{  
    base.OnPreRender(e);
like image 138
Gilles Avatar answered Oct 24 '25 18:10

Gilles