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

Cannot update control inside RadWindow

4 Answers 322 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 17 Feb 2011, 05:39 PM
Hi!

I've been testing this for hours now.

If I add a RadWindowManager with one RadWindow and a Label in it and set it to VisibleOnPageLoad="true".

And a button which changes the Label's text to Label1.Text = "Hello World".
The button is inside a RadAjaxPanel.

I can't get the label to update the value inside the RadWindow.

No matter what I do. Can you give me a simple example on how to make the window update the label when I've pressed the button.

Regards, Jerry

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2011, 10:59 AM
Hello Jerry,

Here is a sample code to achieve the same.
aspx:
<telerik:RadAjaxPanel ID="Panel1" runat="server">
     <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button2_Click" />
  <telerik:RadWindowManager ID="RadWindowManager1" VisibleOnPageLoad="true" VisibleStatusbar="false"
            ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true">
     <Windows>
          <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close">
            <ContentTemplate>
               <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>   
            </ContentTemplate>
         </telerik:RadWindow>
   </Windows>
   </telerik:RadWindowManager>
</telerik:RadAjaxPanel>

C#:
protected void Button2_Click(object sender, EventArgs e)
 {
   Label mybox = RadWindow1.ContentContainer.FindControl("Label1") as Label;
   mybox.Text = "Hello";
 }

Thanks,
Shinu.
0
Roger
Top achievements
Rank 1
answered on 16 Nov 2011, 05:34 PM
Is there a way to achieve this client side?

-Thanks
0
Marin Bratanov
Telerik team
answered on 17 Nov 2011, 04:57 PM
Hello Roger,

Please examine the following online demo: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx. It shows the way to access controls in the ContentTemplate of the RadWindow via JavaScript. Basically you need their ClientID as the RadWindow is an INaming container in this case. This is a general case and you would have the same behavior with other container controls (master pages, update panels, etc).


Best wishes,
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
0
Dhamodharan
Top achievements
Rank 1
answered on 18 Nov 2011, 09:08 AM
Hi,

Hope this will help,

 function Button2_Click(sender, args) {
          document.getElementById('RadWindow1_C_Label1').innerHTML = "test";
          return false;
      }


Thanks,
Dhamu
Tags
Window
Asked by
Jerry
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Roger
Top achievements
Rank 1
Marin Bratanov
Telerik team
Dhamodharan
Top achievements
Rank 1
Share this question
or