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

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

5 Answers 143 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
archimede
Top achievements
Rank 1
archimede asked on 17 Nov 2010, 04:04 PM
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);
}
....................
}

5 Answers, 1 is accepted

Sort by
0
archimede
Top achievements
Rank 1
answered on 17 Nov 2010, 05:55 PM
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
0
Radoslav
Telerik team
answered on 23 Nov 2010, 08:59 AM
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.
0
archimede
Top achievements
Rank 1
answered on 24 Nov 2010, 02:59 PM
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);
}
0
Jun
Top achievements
Rank 1
answered on 03 Jan 2011, 10:02 PM
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!
0
Radoslav
Telerik team
answered on 05 Jan 2011, 10:46 AM
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.
Tags
Ajax
Asked by
archimede
Top achievements
Rank 1
Answers by
archimede
Top achievements
Rank 1
Radoslav
Telerik team
Jun
Top achievements
Rank 1
Share this question
or