Switching views causing "Sys.ArgumentNullException: Value cannot be null" javascript error

2 posts, 0 answers
  1. Venkatesh
    Venkatesh avatar
    88 posts
    Member since:
    Nov 2012

    Posted 30 Dec 2012 Link to this post

    Hi,
    I am using the RadAjaxManager and RadGrid,
    In the page, i have a button, on clicking it, i am changing the view as below:
    CustomMultiView.ActiveViewIndex = 1;

    I am getting the below javascript error:

    Message: Sys.ArgumentNullException: Value cannot be null.
    Parameter name: panelsCreated[3]
    Line: 129
    Char: 12
    Code: 0
    URI: server/ScriptResource.axd?d=RPebyLkP-fhDCOP8R5TjxWPY-4fkPjRpQKETtPt1vJ0oYKjzG0P1oXDrWwqGUYowJk6FNzcl9JDcrVPqxhlevrLUyg2lficlL2Y9_KKnDvF49irZMVbCoI5gJzWm8v_Unf6FfAqjKOclBxnSZZAf9ybMAzMisFKw_edGwuOokTcB0Hr10&t=ffffffffb868b5f4

    I am using Sharepoint 2010. I have seen the below url:
    http://www.telerik.com/community/forums/sharepoint-2010/integrate-ajax-controls/telerik-ajax-issue-with-sharepoint-2010.aspx

    However the changes provided in the url have not helped. How to fix this?
    Thanks
  2. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 02 Jan 2013 Link to this post

    Hi,

     The ajaxifying of the controls in this case should be done in the code behind of the web part as shown below. All ajax settings should be added in the code-behind:

    public class VisualWebPart1 : WebPart
        {
            // Visual Studio might automatically update this path when you change the Visual Web Part project item.
            private const string _ascxPath = @"~/_CONTROLTEMPLATES/VisualWebPartProject1/VisualWebPart1/VisualWebPart1UserControl.ascx";
            RadAjaxManager ajaxmgr;
     
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                ajaxmgr = RadAjaxManager.GetCurrent(Page);
                if (ajaxmgr == null)
                {
                    ajaxmgr = new RadAjaxManager();
                    Page.Items.Add(typeof(RadAjaxManager), ajaxmgr);
                }
     
                if (Page.Form != null)
                {
                    Page.Form.Controls.AddAt(0, ajaxmgr);
                }
                EnsureChildControls();
            }
     
            protected override void CreateChildControls()
            {
                Control control = Page.LoadControl(_ascxPath);
                Controls.Add(control);
     
                MultiView multiView = control.FindControl("CustomMultiView") as MultiView;
                
                //Find more controls to add to the ajax settings
                if (ajaxmgr != null)
                {
                    AjaxSetting ajaxSetting = new AjaxSetting();
     
                    ajaxSetting.AjaxControlID = multiView.ID;
                    ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl(multiView.ID, string.Empty));
     
                    ajaxmgr.AjaxSettings.Add(ajaxSetting);
                }
            }
        }


    Greetings,
    Marin
    the Telerik team
    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 their blog feed now.
Back to Top