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

[Solved] java script function doesn't call with in RadAjaxManager1_AjaxRequest function

1 Answer 81 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, 10:47 AM
it doesn't call check() function within RadAjaxManager1_AjaxRequest() while timer is controlled within radajaxmanager.
anyone help me. plz.
thx.


<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;
        }
        }
    }

function check()
{
alert("check_request");
}
</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");
        string loadscript3 = "check();";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "loadscript3", loadscript3, true);
        }
 else
        {
            MessageBox.Show("no");
         }




1 Answer, 1 is accepted

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

Could you please specify if the preciding code is in a page or user control? You can try modifying your code as below and see if it makes any difference:

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


Sincerely yours,
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.
Tags
General Discussions
Asked by
priya nallaperumal
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or