'undefined' is null or not an object Error using RadAjaxManagerProxy into User Control

6 posts, 0 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 17 Nov 2010 Link to this post

    I've a RadAjaxManager into a MasterPage and i want to refresh a RadGrid and a FormView into a User Control when I click to imbRefresh and I see this JS error:

    'undefined' is null or not an object 

    this is the code:

    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            function Refresh() {
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequestWithTarget('<%= imbRefresh.UniqueID %>', '');
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManagerProxy ID="rmpManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="imbRefresh">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="frv" LoadingPanelID="rlp" />                
                    <telerik:AjaxUpdatedControl ControlID="rdg" LoadingPanelID="rlp" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadAjaxLoadingPanel ID="rlp" runat="server" Skin="MachinaWeb">
    </telerik:RadAjaxLoadingPanel>
     
    <asp:ImageButton ID="imbRefresh" runat="server" AlternateText="Refresh" CausesValidation="False"
        ImageUrl="~/Images/Refresh-25.png" OnClick="imbRefresh_Click" OnClientClick="Refresh(); return false;" />
     
    <mwc:FormView ID="frvStabilimento" runat="server" DataSourceID="ods2">
    ......................
    </mwc:FormView>
     
    <mwc:RadGrid ID="rdg" runat="server" DataSourceID="ods"
        Height="340px" Type="Edit">
    ...............
    </mwc:RadGrid>
     
     
    Code Behind
     
        protected void imbRefresh_Click(object sender, EventArgs e)
        {
            rdg.Rebind();
            frv.DataBind();
        }

    mwc are Server Controls that exted the original classes
    Example:
    Server Control RadGrid.cs is:

    namespace MWC.ServerControls
    {
        public class RadGrid : Telerik.Web.UI.RadGrid
        {
            protected override void OnInit(EventArgs e)
            {
               //default value in every RadGrid          
                AllowMultiRowSelection = false;
                AutoGenerateColumns = false;
                EnableEmbeddedSkins = false;
                EnableAjaxSkinRendering = false;
                ShowFooter = false;
    ...............................
               base.OnInit(e);
    }
    ....................
    }
  2. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 17 Nov 2010 Link to this post

    this is the javascript that triggers the error

    /* START MicrosoftAjax.js */
    2//----------------------------------------------------------
    3// Copyright (C) Microsoft Corporation. All rights reserved.
    4//----------------------------------------------------------
    5// MicrosoftAjax.js
    6Function.__typeName="Function";Function.__class=true;Function.createCallback=function(b,a){return function(){var e=arguments.length;if(e>0){var d=[];for(var c=0;c<e;c++)d[c]=arguments[c];d[e]=a;return b.apply(this,d)}return
    .........................................................................................
    function(a){Sys.UI.Control.initializeBase(this);this._element=a;a.control=this;
    ................................................
    9/* END MicrosoftAjax.js */
    10/* START MicrosoftAjaxWebForms.js */
    11//----------------------------------------------------------

    a.control is undefined is null or not an object
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 23 Nov 2010 Link to this post

    Hello Archimede,

    I tried to reproduce the described issue but to no avail. I am sending you a simple example which is based on your code. please check it out and let me know what differs in your case.
    Looking forward for your reply.

    Kind regards,
    Radoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  5. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 24 Nov 2010 Link to this post

    Thank you for the example!

    After netting out the page I discovered that the error was due to this server control inside the FormView

    public class RadDatePicker : Telerik.Web.UI.RadDatePicker
        {
            private bool _readOnly;       
            private TextBox tb = new TextBox();
            public bool ReadOnly
            {
                get
                {
                    return _readOnly;
                }
                set
                {
                    _readOnly = value;
                }
            }
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
            {
                if (_readOnly)
                {
                    if (this.SelectedDate.HasValue)
                    {                  
                        tb.Text = this.SelectedDate.Value.ToShortDateString();                   
                    }
                    else
                    {
                        tb.Text = "";
                    }               
                    tb.RenderControl(writer);
                }
                else
                {              
                    base.Render(writer);
                }
            }
        }

    after replacing the render event with this code below it works fine even if I do not know why that would cause javascript error

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        if (_readOnly)
        {                              
            EnableTyping = false;
            DatePopupButton.Visible = false;
            DateInput.ForeColor = System.Drawing.Color.Black;            
        }
     
        base.Render(writer);
    }
  6. Jun
    Jun avatar
    47 posts
    Member since:
    Sep 2006

    Posted 03 Jan 2011 Link to this post

    The problem described here is not resolved yet. I am getting the same javascript error as I described in this thread:

    Server control with telerik control inside an ajaxified formview

    Thanks!
  7. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 05 Jan 2011 Link to this post

    To Francesco:
    When the _readOnly variable is true the base.Render() method is not called, however this could lead to the described issue.
    To Jun:
    Based on the provided information it is hard to say what is caused the described issue. Could you please send us a sample where we could replicate the issue in order to debug it locally and get to the source of the issue. You could open a formal support ticket from your Telerik account and attach a ZIP file there. Thus we will be able to gather more details about your scenario and to provide you a solution.

    Regards,
    Radoslav
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017