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

RadAjaxPanel.ajaxRequest() method causes Javascript error

5 Answers 334 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
vn
Top achievements
Rank 1
vn asked on 23 May 2008, 07:20 AM
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);  
 
        } 

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 26 May 2008, 12:30 PM
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
0
vn
Top achievements
Rank 1
answered on 27 May 2008, 05:54 AM
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
0
Steve
Telerik team
answered on 27 May 2008, 07:33 AM
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
0
Rohan
Top achievements
Rank 1
answered on 04 Dec 2012, 10:01 AM
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 .
0
Maria Ilieva
Telerik team
answered on 07 Dec 2012, 11:16 AM
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.
Tags
Ajax
Asked by
vn
Top achievements
Rank 1
Answers by
Steve
Telerik team
vn
Top achievements
Rank 1
Rohan
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or