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

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

1 Answer 44 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Venkatesh
Top achievements
Rank 1
Venkatesh asked on 31 Dec 2012, 04:17 AM
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

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 02 Jan 2013, 10:29 AM
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.
Tags
Ajax
Asked by
Venkatesh
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or