This is a migrated thread and some comments may be shown as answers.

[Solved] how can i stop the timer

3 Answers 187 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
priya nallaperumal
Top achievements
Rank 1
priya nallaperumal asked on 08 Feb 2010, 09:36 AM
 
how can i stop the timer. timer is controled within radajaxmanager. but timer1.enabled = false is not working.
i controlled RadAjaxManager1 instead of Timer1 in AjaxControlID . but page gets refreshed...
what i do.. plz help me...



<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Timer1">
        <UpdatedControls >
        <telerik:AjaxUpdatedControl ControlID="HiddenField1"/>
        </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:HiddenField ID="HiddenField1" runat="server" />
        <asp:HiddenField ID="HiddenField2" runat="server" />
        <br />
        <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
        </asp:Timer>
 <telerik:RadScriptBlock runat="server" ID="sctblk">
        <script type="text/javascript">
 function checkval() {
 
  if (document.getElementById("HiddenField1").value == "ajax") {
        var result = confirm("Are you sure accept the users?");
        if (result) {
        var ajaxManager = $find("<%=RadAjaxManager1.ClientID %>");
        ajaxManager.ajaxRequest('yes');
            return ;
            
        }
        else {
            var ajaxManager = $find('<%= RadAjaxManager1.ClientID %>');
             ajaxManager.ajaxRequest('no');
            return;
        }
        }
    }
</script>


 function checkval() {
 alert("check");
  if (document.getElementById("HiddenField1").value == "ajax") {
        var result = confirm("Are you sure accept the users?");
        if (result) {
       // alert("if");
       //var ajaxManager="<%=RadAjaxManager1.ClientID %>";
          var ajaxManager = $find("<%=RadAjaxManager1.ClientID %>");

          //  alert(ajaxManager);
            //document.getElementById("HiddenField2").value="if";
            document.getElementById("HiddenField1").value ="kkk";
            ajaxManager.ajaxRequest('yes');
            return ;
            
        }
        else {
     //   alert("else");
        
            var ajaxManager = $find('<%= RadAjaxManager1.ClientID %>');
           // alert(ajaxManager);
          //  document.getElementById("HiddenField2").value="else";
                      document.getElementById("HiddenField1").value ="kkk";

            ajaxManager.ajaxRequest('no');
            return;
        }
        }
    }
</script>

protected void Timer1_Tick(object sender, EventArgs e)
    {
        
        HiddenField1.Value = "ajax";
        string loadscript2 = "function f(){checkval()} Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "loadscript2", loadscript2, true);
}
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        Timer1.Enabled = false;
        if (e.Argument == "yes")
        {          
          MessageBox.Show("yes");
          }
 else
        {
            MessageBox.Show("no");
          
        }





3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 11 Feb 2010, 08:08 AM
Hello priya,

Try modifying the ajax settings as below and see if the Timer is disabled properly now:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Timer1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="HiddenField1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Timer1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>


Best wishes,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
priya nallaperumal
Top achievements
Rank 1
answered on 11 Feb 2010, 10:23 AM
thanks for your response. but this code is not working..

The method or operation is not implemented.

error is displayed while controlling "Timer1" within the AjaxUpdatedControl

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Timer1">
        <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="HiddenField1" />
        </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
        <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="Timer1" />
        
        </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>

0
Iana Tsolova
Telerik team
answered on 12 Feb 2010, 11:48 AM
Hi priya,

Please excuse me for misleading you. 
I was able to replicate the error and it is thrown any time you add the Timer controls as on of the UpdateControls in RadAjaxManager setting. However, I prepared a sample project where a Timer control is disabled properly on a button click or on manually invoked ajax request.
Please check it out and let me know if it works as expected and what differs in your case.

All the best,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
priya nallaperumal
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
priya nallaperumal
Top achievements
Rank 1
Share this question
or