ajax manager is null

3 posts, 0 answers
  1. priya nallaperumal
    priya nallaperumal avatar
    23 posts
    Member since:
    Nov 2009

    Posted 24 Jan 2011 Link to this post

    Hello!
    i have attached my code below.


     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
           <telerik:AjaxUpdatedControl ControlID="panel1" />
          <telerik:AjaxUpdatedControl ControlID="samplediv" />
            </UpdatedControls>
            </telerik:AjaxSetting>
            </AjaxSettings>
           <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Timer1" >
            <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="samplediv" />
            <telerik:AjaxUpdatedControl ControlID="ajaxbtn" />
            </UpdatedControls>
            </telerik:AjaxSetting>
            </AjaxSettings>
            </telerik:RadAjaxManager>
            <br />
             <asp:Panel ID="panel1" runat="server">
            <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" Enabled="false">
            </asp:Timer></asp:Panel>
            <div id="samplediv" runat="server" style="border:solid 1px grey;height:180px;width:250px;overflow:scroll;" />  
    <telerik:RadCodeBlock ID="radblk" runat="server">
     <script type="text/javascript">
    function chattext()
    {
        var ajaxmagr = $find("<%=RadAjaxManager1.ClientID%>");
        alert(ajaxmagr);
        ajaxmagr.ajaxRequest("chat");
    }

    </script>       
            </telerik:RadCodeBlock>


    cs code..


    protected void Timer1_Tick(object sender, EventArgs e)
        {
            string s = "chattext();";
            RadScriptManager.RegisterStartupScript(this, this.GetType(), "s", s, true);
        }
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e.Argument == "chat")
            {
                
                samplediv.InnerHtml += " sample text <br/>";
               
            }
        }






    i want to call a js funtion in timer tick.  but i got ajaxmgr as null in js alert.
    whats wrong in my code? 

    thanks.
    priya.

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 27 Jan 2011 Link to this post

    Hello,

    It seems that the Startup script is registered too early on the page and the RadAjaxManager is still not initialized. please try to set time out like this:
    <script type="text/javascript">
         function chattext() {
             setTimeout(function () {
                 var ajaxmagr = $find("<%= RadAjaxManager1.ClientID %>");
                 alert(ajaxmagr);
                 ajaxmagr.ajaxRequest("chat");
            }, 0);
         }
      
    </script>
     
    Let me know if this helps.

    Kind regards,
    Maria Ilieva
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prashant Nandha
    Prashant  Nandha avatar
    2 posts
    Member since:
    Jul 2009

    Posted 28 Oct 2013 Link to this post

    This is great, it worked for me.
Back to Top