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

JS undefined type for popup RadControl

2 Answers 65 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mauro
Top achievements
Rank 1
Mauro asked on 13 Jun 2013, 09:45 AM
Hello,
I have a RadGrid with an Edit/Insert popup form based on a template. The RadGrid is AJAX enabled programmatically in the Page_Load() method.

RadAjaxManager ram = RadAjaxManager.GetCurrent(Page);
ram.AjaxSettings.AddAjaxSetting(RadGrid1, RadGrid1, RadAjaxLoadingPanel1);
<telerik:RadScriptManager id="ScriptManager" runat="server"
  EnableScriptCombine="true" EnablePageMethods="false" EnablePartialRendering="true"
  EnableScriptGlobalization="false" EnableScriptLocalization="true">
  <Scripts>
    <asp:scriptreference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"></asp:scriptreference>
    <asp:scriptreference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js"></asp:scriptreference>
    <asp:scriptreference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js"></asp:scriptreference>
  </Scripts>
</telerik:RadScriptManager>
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    // Add an RadAjaxManager to the page.
    SetUpAjaxManagerOnPage();
    // Create child controls (if necessary).
    EnsureChildControls();
}
protected void SetUpAjaxManagerOnPage()
{
    // Check if there is already an Ajax Manager somewhere on the page.
    RadAjaxManager currentAjaxManager = RadAjaxManager.GetCurrent(Page);
    if (currentAjaxManager == null)
    {
        Page.Form.Controls.AddAt(0, AjaxManager);
        Page.Items.Add(typeof(RadAjaxManager), AjaxManager);
    }
}
protected virtual RadAjaxManager AjaxManager
{
    get
    {
        if (_ajaxManager == null)
        {
            _ajaxManager = RadAjaxManager.GetCurrent(Page);
            if (_ajaxManager == null)
            {
                _ajaxManager = new RadAjaxManager() { ID = "RadAjaxManager1" };
            }
        }
        return _ajaxManager;
    }
}


In the template there is a RadListBox.

<telerik:RadListBox runat="server"
  ID="RadListBoxCharacteristicValues"
  DataValueField="CharacteristicValuedID"
  DataTextField="CharacteristicVal"
  AllowReorder="true"
  AllowDelete="true"
  EnableDragAndDrop="true"
  Height="150px" Width="240px" />

When I click on the Edit or Add buttons nothing happens but a Javascript exception is thrown:

Uncaught Sys.ArgumentUndefinedException: Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: type
  1. Error$create ScriptResource.axd:222
    Error$argumentUndefined ScriptResource.axd:346
    Function$_validateParameterType         ScriptResource.axd:130
    Function$_validateParameter ScriptResource.axd:99
    Function$_validateParams ScriptResource.axd:67
    Sys$Component$create ScriptResource.axd:2698
    (anonymous function) TechnicalData.aspx:7
    Sys$_Application$add_init ScriptResource.axd:3991
    (anonymous function) TechnicalData.aspx:1
    ...


I spent some time debugging the client code to find out what was causing such exception and it seemed that Javascript had no knowledge of the RadListBox (type undefined).

I found a temporary workaround by placing a dummy empty RadListBox in another place of the page.

This is not peculiar to RadListBox controls as it happens also with all other RadControls.

My conclusion is that if the edit form template contains RadControls which are nowhere else defined on the page, the associated client scripts and definitions are not properly loaded when using AJAX. Without enabling AJAX behavior everything works fine.

What am I doing wrong? Is there a solution?

Thanks in advance,

Mauro

Telerik version: 2013.1.220.35
Language: C#
Platform: Sharepoint Server 2010

2 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 18 Jun 2013, 08:37 AM
Hello Mauro,

Could you please elaborate more on how are the the grid and template used for edit/insert created? Following the scenario I tried to reproduce the described problem but was unable to do so. Could you please review the attached website and tell us what differs in your case? Also bare in mind that only one instance of the RadAjaxManager can be added to the page. That said the logic in the SetUpAjaxManagerOnPage method will cause an error.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Mauro
Top achievements
Rank 1
answered on 19 Jun 2013, 06:40 AM
Hello Angel and thank you for your time.

Since the same code worked fine on one of my colleagues' development environment, I compared the two Sharepoint installations and found out that the only difference was a missing hotfix. After installing KB2597150 the code worked as expected, so it seems the problem was caused by a MS Sharepoint bug.

I also found this related old post.

Regards,

Mauro
Tags
Ajax
Asked by
Mauro
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Mauro
Top achievements
Rank 1
Share this question
or