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

Refresh controls out of ajax panel with a control in ajax panel

2 Answers 138 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Silvio Silva Junior
Top achievements
Rank 2
Silvio Silva Junior asked on 19 May 2010, 02:59 PM
Hello everybody.

I have a simple question.

I have a page with 1 textbox and 1 grid.

My grid is in an ajax panel, and my textbox not. When I make some action in grid (insert, update, delete) I'm trying to change the textbox's value, in the event, like:

Grid Update Event:
TextBox1.Text = "blablabla";

but I can't. What's the best solution for this my friends?

Thanks.

Regards.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 May 2010, 01:08 PM
Hi,

#1:
I tried following approach in my application for a similar scenario.

c#:
  
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        {           
             string script = "document.getElementById('" + TextBox1.ClientID + "').innerText ='TestString'"; 
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "show", script, true); 
        } 

#2:
Another suggestion is to use RadAjaxManager. The RadAjaxPanel functionality can be simulated completely by the manager - simply replace the AJAX Panel with an ASP:Panel.

aspx:
      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
           <AjaxSettings> 
               <telerik:AjaxSetting AjaxControlID="RadGrid1"
                   <UpdatedControls> 
                       <telerik:AjaxUpdatedControl ControlID="Panel" /> 
                       <telerik:AjaxUpdatedControl ControlID="TextBox1" /> 
                   </UpdatedControls> 
               </telerik:AjaxSetting> 
           </AjaxSettings> 
       </telerik:RadAjaxManager> 
        
 
        <asp:Panel ID="Panel" runat="server"
            <telerik:RadGrid ID="RadGrid1" AllowSorting="True" PageSize="20" ShowGroupPanel="True" 
                AllowPaging="True" AllowMultiRowSelection="True" AllowFilteringByColumn="true" 
                AutoGenerateColumns="true" EnableViewState="true" runat="server" GridLines="None" 
                 OnItemCommand="RadGrid1_ItemCommand"
            </telerik:RadGrid> 
        </asp:Panel> 
         
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 

The modified version of the code will perform the same task as if you use RadAjaxPanel instead of manager: I tried these two approaches to get it works.



Hope this helps,
Princy.
0
Silvio Silva Junior
Top achievements
Rank 2
answered on 20 May 2010, 02:19 PM
Hello Princy, and thanks for the answer.

The first suggestion doesn't work.

With the second suggestion, I got this error when I load the page: 

Script control '' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl


My aspx file is like this:

              <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">       
               <AjaxSettings>       
                   <telerik:AjaxSetting AjaxControlID="MyGrid">       
                       <UpdatedControls>       
                           <telerik:AjaxUpdatedControl ControlID="Panel" />       
                           <telerik:AjaxUpdatedControl ControlID="TextBox1" />       
                       </UpdatedControls>       
                   </telerik:AjaxSetting>       
               </AjaxSettings>       
           </telerik:RadAjaxManager>       
           <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server">     
            </telerik:RadAjaxLoadingPanel>    
            <telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel">     
           <asp:Panel ID="Panel" runat="server">      
                MyGrid
            </asp:Panel>    
             </telerik:RadAjaxPanel>    
 

And I tryed something like this:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">          
               <AjaxSettings>          
                   <telerik:AjaxSetting AjaxControlID="MyGrid">          
                       <UpdatedControls>          
                           <telerik:AjaxUpdatedControl ControlID="Panel" />          
                           <telerik:AjaxUpdatedControl ControlID="TextBox1" />          
                       </UpdatedControls>          
                   </telerik:AjaxSetting>          
               </AjaxSettings>          
           </telerik:RadAjaxManager>                      
           <asp:Panel ID="Panel" runat="server">         
                MyGrid   
            </asp:Panel>       
 
 

But I got the same error.

What am I doing wrong?

Regards.
Tags
Ajax
Asked by
Silvio Silva Junior
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Silvio Silva Junior
Top achievements
Rank 2
Share this question
or