Error Uncaught TypeError: Cannot read property 'ajaxRequest' of null

2 posts, 0 answers
  1. Support
    Support avatar
    14 posts
    Member since:
    Feb 2012

    Posted 22 Sep 2016 Link to this post

    Hi, I have an ascx file that contains a RadNotification and a timer.

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                <script type="text/javascript">
                    function OnClientUpdated(sender, args) {
                        $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
                    function UpdateWithoutPopup() {
                        var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
    <telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server">
                    <telerik:AjaxSetting AjaxControlID="Timer1">
                            <telerik:AjaxUpdatedControl ControlID="RadNotification1" />
    <asp:Timer ID="Timer1" runat="server" Interval="6000" OnTick="Timer1_Tick" />
     <telerik:RadNotification RenderMode="Lightweight" id="RadNotification1" runat="server" loadcontenton="EveryShow"
            width="300" height="150" animation="Fade" enableroundedcorners="true" enableshadow="true"
            title="Received messages" offsetx="-20" offsety="-20" onclientupdated="OnClientUpdated"
            titleicon="none" autoclosedelay="5000" Skin="Bootstrap">
                <asp:Image ID="Image1" runat="server" CssClass="Max75" />
                <asp:Literal ID="lbl" runat="server"></asp:Literal>

    the timer makes the checks and if necessary displays a popup, another calls a function

    public void Timer1_Tick(object sender, EventArgs e)
            if (Check())
                string script = "UpdateWithoutPopup()";
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true);

    When I show the popup everything works fine when if I call the error function I get the error:

    default.aspx:502 Uncaught TypeError: Cannot read property 'ajaxRequest' of null

    how do I fix?

    thanks in advance

  2. Eyup
    Eyup avatar
    3320 posts

    Posted 27 Sep 2016 Link to this post


    The issue is most probably caused by the following line:
    ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true);

    It is not supported to call scripts in the fashion above when using AJAX. You can check the following live sample:

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top