JS undefined type for popup RadControl

3 posts, 0 answers
  1. Mauro
    Mauro avatar
    4 posts
    Member since:
    Jun 2013

    Posted 13 Jun 2013 Link to this post

    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. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 18 Jun 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mauro
    Mauro avatar
    4 posts
    Member since:
    Jun 2013

    Posted 19 Jun 2013 Link to this post

    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
Back to Top