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

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

13 Answers 213 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 13 Dec 2010, 05:16 PM
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

13 Answers, 1 is accepted

Sort by
0
Rafaga2k
Top achievements
Rank 1
answered on 13 Dec 2010, 07:39 PM
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
0
Alberto
Top achievements
Rank 1
answered on 14 Dec 2010, 10:02 AM
the error only occurs if I use ajax so I think it is the right section

Digita il testo o l'indirizzo di un sito web oppure traduci un documento.
why the objects inside the TemplateColumn can't be readonly?
0
Rafaga2k
Top achievements
Rank 1
answered on 14 Dec 2010, 09:45 PM
forget that i was wrong .. sorry hehehehe
0
Vasil
Telerik team
answered on 15 Dec 2010, 12:12 PM
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.
0
Alberto
Top achievements
Rank 1
answered on 17 Dec 2010, 03:40 PM
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?
0
Vasil
Telerik team
answered on 21 Dec 2010, 03:03 PM
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.
0
Alberto
Top achievements
Rank 1
answered on 21 Dec 2010, 04:33 PM
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
0
Alberto
Top achievements
Rank 1
answered on 03 Jan 2011, 03:33 PM
is there any problem to run the project?

well ask me any questions

thanks
0
Vasil
Telerik team
answered on 06 Jan 2011, 10:51 AM
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.
0
Alberto
Top achievements
Rank 1
answered on 28 Jan 2011, 10:46 AM
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
0
Vasil
Telerik team
answered on 02 Feb 2011, 04:38 PM
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.
0
Alberto
Top achievements
Rank 1
answered on 22 Feb 2011, 04:04 PM
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);
        }
    }
0
Vasil
Telerik team
answered on 25 Feb 2011, 02:58 PM
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!
Tags
Ajax
Asked by
Alberto
Top achievements
Rank 1
Answers by
Rafaga2k
Top achievements
Rank 1
Alberto
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or