RadAjaxPanel.ajaxRequest() method causes Javascript error

6 posts, 0 answers
  1. vn
    vn avatar
    12 posts
    Member since:
    Jul 2007

    Posted 23 May 2008 Link to this post

    Hi,

    Can someone please tell me why I got the a javascript error when I click the "Refresh using ajaxPanel.ajaxRequest()" button the second time?

    Thank you,

    Vincent


    Javascript Error:
    Sys.ArgumentException: Value must not be null for Controls and Behaviors.    Parameter name:  element

    Here are my codes:

    WebForm1.aspx
            <asp:ScriptManager runat="server" ID="scriptMgr" /> 
              
            <uc1:UserControl1 ID="UserControl1" runat="server" />     
            <br /> 
              
            <asp:Button runat="server" ID="btnRefreshAjaxManager" Text="Refresh AjaxManager" /> 
              
            <telerik:RadAjaxManager runat="server" ID="ajaxMgr">  
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="btnRefreshAjaxManager">  
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="UserControl1"/>  
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager>    

    UserControl1.ascx:
    <script language="javascript">  
        function Refresh( controlId )  
        {  
            var panel = $find(controlId );  
            panel.ajaxRequest();  
        }  
    </script> 
     
     
    <telerik:RadAjaxPanel runat="server" ID="ajaxPanel" > 
        <asp:TextBox runat="server" ID="TextBox1" /> 
        <asp:Label runat="server" ID="Label1" /> 
        <br /> 
        <asp:Button runat="server" ID="btnRefreshAjaxPanel" Text="Refresh AjaxPanel" /> 
    </telerik:RadAjaxPanel> 
     
    <br /> 
    <asp:Button runat="server" ID="btnRefreshJS" Text="Refresh using ajaxPanel.ajaxRequest()" /> 

    UserControl1.ascx.cs
            protected void Page_Load(object sender, EventArgs e)  
            {  
                TextBox1.Text = DateTime.Now.ToString();  
     
                thisthis.Label1.Text = this.ajaxPanel.ClientID;  
     
                this.btnRefreshJS.OnClientClick = string.Format( "Refresh( '{0}' ); return false;", ajaxPanel.ClientID);  
     
            } 
  2. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 26 May 2008 Link to this post

    Hello vn,

    I just tested your code and could not reproduce the error you've encountered. I've attached the sample I've used for my testing purposes. Give it a spin and let us know what differs in your case.

    Regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. vn
    vn avatar
    12 posts
    Member since:
    Jul 2007

    Posted 27 May 2008 Link to this post

    Hi Steve,

    Thank you for the code.  The reason why you cannot reproduce the problem because the value of the ControlID property of the AjaxUpdatedControl is not set to the name of the user control.  The value of the ControlID property suppose to  be "WebUsercontrol1" since that is what you use to name the user control.

    Please change the following line in the Default2.aspx from:
    <telerik:AjaxUpdatedControl ControlID="UserControl1"/>  

    To:
     <telerik:AjaxUpdatedControl ControlID="WebUserControl1"/>  

    Please let me know if you still cannot reproduce it.

    The reason why I use the RadAjaxManager on the parent page is only load and show content of user control (using ajax) if the  user click on the btnRefreshAjaxManager button (I should have name it btnShowUserControl instead).

    Thank you,

    Vincent
  4. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 27 May 2008 Link to this post

    Hello vn,

    Thank you for the clarification and sorry for the confusion - I've dragged & drop the user control when making the test page and have forgotten to change the IDs. Indeed problem will occur when messing both AjaxManager and AjaxPanel (more info here). Basically in such scenarios any request is being handled twice - once from the AjaxPanel and the AjaxManager tries to handle it too as the whole user control is specified as updated control. The best way to proceed in such cases is use the AjaxManager to handle all the ajaxification and replace the AjaxPanel with asp:Panel.

    Greetings,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 04 Dec 2012 Link to this post

    Hi all ,

    I have one user control with rad grid , in that user control user selected row , after selected row the selected row value are returned to page thought the delegate and delegate event update value of user control to page control such as text box and drop down , this is working without radajaxpanle , but when i put the radajaxpanel to page value of user control not updating on page ... my remaining things such as delegate of user control and event of user control all thing are working .... just i want to update control value with in radajaxpanel
    ,please provide any document or example .

    Thanks .
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Dec 2012 Link to this post

    Hello Rohan,

    The presented scenario is better to be achieved with RadAjaxManager control instead of RadAjaxPanel. This way you could access the main manager using its GetCurrent() method and add programmatic settings in which the needed control on the content page is updated by the RadGrid from the UserControl. See the online resources below for more information on this matter:
    http://www.telerik.com/help/aspnet-ajax/ajax-masterpage-update-everywhere.html
    http://www.telerik.com/help/aspnet-ajax/ajax-user-controls.html

    Kind regards,
    Maria Ilieva
    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