Error 'undefined' is null or not an object opening a radgrid that uses a server control into GridTemplateColumn

14 posts, 0 answers
  1. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 13 Dec 2010 Link to this post

    I created the following server control by creating the readonly property:

        public class RadComboBox : Telerik.Web.UI.RadComboBox
        {
            private Label lbl = new Label();
            private bool _readOnly;
            public bool ReadOnly
            {
                get
                {
                    return _readOnly;
                }
                set
                {
                    _readOnly = value;
                }
            }
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (_readOnly)
            {                        
                lbl.Text = this.Text;
                lbl.ReadOnly = true;
                lbl.RenderControl(writer);
            }
            else
            {
                base.Render(writer);
            }
        }
    if I use this object with RadGrid in GridTemplateColumn fixed in the ItemTemplate ReadOnly to true cause the following JS error message:

    Error 'undefined' is null or not an object

    radgrid is into a RadAjaxPanel and uses a masterpage that call the RadScriptManager and RadAjaxManager.

    I tried to use ajaxSettings instead of RadAjaxPanel but the same error.

    how can I fix it?

    thanks for any replies
  2. Rafaga2k
    Rafaga2k avatar
    14 posts
    Member since:
    Nov 2010

    Posted 13 Dec 2010 Link to this post

    somewhere i read that objects into the templatecolumn cannot be readonly (not 100% sure) 100% wrong ...well whatever i think that this must be in Grid forum not Ajax
  3. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 14 Dec 2010 Link to this post

    the error only occurs if I use ajax so I think it is the right section

    why the objects inside the TemplateColumn can't be readonly?
  4. Rafaga2k
    Rafaga2k avatar
    14 posts
    Member since:
    Nov 2010

    Posted 14 Dec 2010 Link to this post

    forget that i was wrong .. sorry hehehehe
  5. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 15 Dec 2010 Link to this post

    Hi Alberto,

    The ASP:Label control by default has no ReadOnly property. Is the Label you use is your modified control that inherits asp:Label?
    Can you make sample web application which represents the issue and attach it?

    Greetings,
    Vasil
    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.
  6. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 17 Dec 2010 Link to this post

    Yes it is a readonly property that I added to my control that inherits asp:Label to set a CssClass if it is read-only,
    could you give me an e-mail to send the project with an example?
  7. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 21 Dec 2010 Link to this post

    Hello Alberto,

    We provide support only through our support ticketing system. If you want to send us a project then open a formal support ticket or upload it in some public web site from where we can download it.

    Kind regards,
    Vasil
    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.
  8. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 21 Dec 2010 Link to this post

    ok this is the project with the error, the page AutoLogin.aspx has been described as the error

    http://www.ali3.it/st_archimede/machina_download/TestTelerik21122010.rar

    Thank you in advance
  9. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 03 Jan 2011 Link to this post

    is there any problem to run the project?

    well ask me any questions

    thanks
  10. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 06 Jan 2011 Link to this post

    Hi Alberto,

    We debugged the project and investigate the issue.
    Actually you get the undefined error in all the pages. Not only in the ajaxified. The difference is that this error  does not prevent the page to work fine when it postbacks. You can use FireBug in Firefox to see these errors.
    After adding telerik columns in the grid and removing mwc columns the problem disappeared. We are not sure which of the mwc columns causes the error. You can debug them one by one and determinate from where the problem comes.

    Another error we get on clicking "popup with error" is:
    "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."
    This error occurs because the code blocks should be escaped when using Ajax. In order to fix this wrap the code in which you use inline server tags into a RadCodeBlock. And if this does not solve the problem place your controls into RadAjaxPanel instead of adding them into the RadAjaxManager.

    All the best,
    Vasil
    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.
  11. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 28 Jan 2011 Link to this post

    Thanks for having debugged the project,

    if the server control render event of RadComboBox the control is converted to Label the error is generated

    if (_geiContainer != null && !_geiContainer.IsInEditMode)
    {
    lbl.Text = this.Text;
    lbl.ReadOnly = true;
    lbl.RenderControl(writer);
    }

    if I insert this code the error is not generated, but the code I found to disable the click event of RadComboBox does not work:

    if (_geiContainer != null && !_geiContainer.IsInEditMode)
    {
    Skin = "";
    OnClientLoad = "onLoadComboReadOnly";                           
    base.Render(writer);
    }
     
    JS:
    function onLoadComboReadOnly(sender) {
        var input = sender.get_inputDomElement();
        input.readOnly = true;
        $telerik.$(input).keydown(function (e) { return false; });
        sender.add_dropDownOpening(function (s, e) { e.set_cancel(true); });
    }

    By various tests in a project without a server control function onLoadComboReadOnly JS only works if the object is out RadMultiPage

    belonging to this function I was trying to convert the RadComboBox in a label in order to optimize the time the page was created by solving the error postback

    any help is much appreciated
  12. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 02 Feb 2011 Link to this post

    Hello Alberto,

    Why don't you use asp:Label instead of RadComboBox in the first place? What you mean by "convert the control"?

    Best wishes,
    Vasil
    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.
  13. Alberto
    Alberto avatar
    11 posts
    Member since:
    Nov 2010

    Posted 22 Feb 2011 Link to this post

    I do not use the label otherwise loading the combo unnecessarily delaying the opening of the page.

    to optimize the time of load, if the RadComboBox is readonly I wanted to convert the control by overriding the Render displaying only a Label without loading elements of the DropDownList with this code:

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (_readOnly)
            {                       
                lbl.Text = this.Text;
                lbl.ReadOnly = true;
                lbl.RenderControl(writer);
            }
            else
            {
                base.Render(writer);
            }
        }
  14. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 25 Feb 2011 Link to this post

    Hi Alberto,

    I suppose you have copied the disable click event for the RadComboBox from this forum thread:
    http://www.telerik.com/community/forums/aspnet-ajax/combobox/readonly.aspx
    This will work only for real RadComboBox. But when you render Label instead of combo, the code is expected not to work. So if you need to handle OnLoad event then check if the control is label or not. If the control is just a label, do not change its keydown function.

    Best wishes,
    Vasil
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top