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

How to get the values of Rad Window ContentTemplate

5 Answers 261 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
phani
Top achievements
Rank 1
phani asked on 29 May 2012, 01:04 PM
HI, 
i am using rad window ContentTemplate with two RadDateTimePicker  contols and one button.

when dates are selected by user and on button click event, i want to know what dates the user has selected in code behind. can some one please help me.

<telerik:RadWindowManager ID="RadWindowManager1" Title=" Search Filter" ShowContentDuringLoad="TRUE" VisibleStatusbar="false"
        ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true" 
    Animation="FlyIn" EnableTheming="False" AnimationDuration="500">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" Modal="true"  RestrictionZoneID="NavigateUrlZone" runat="server" Behaviors="Close" OnClientClose="OnClientClose"
                Width="400">
                <ContentTemplate>
                 <br />
                <br />
                    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
                 From:
                     <telerik:RadDateTimePicker ID="DtFromdate" runat="server">                 
                     </telerik:RadDateTimePicker>
                    <asp:RequiredFieldValidator ID="Rffromdate" runat="server"  ControlToValidate = "DtFromdate" Text="Select date"                              ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                    <telerik:RadDateTimePicker ID="DtTodate" runat="server">                
                     </telerik:RadDateTimePicker>                     
                     <asp:RequiredFieldValidator  ID="Rftodate" runat="server" Text="Select date" ControlToValidate = "DtTodate"                                         ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                    <asp:Button ID="BtnSubmitdata" OnClick="BtnParameters_Click" runat="server" Text="Filter" />

----------------------------------------------------------------------------------------------------------------------------------------------------------------
on code behind i am trying to access the above controls but is is not returning any value. 

 RadDateTimePicker fromdt = RadWindow1.ContentContainer.FindControl("Rffromdate") as RadDateTimePicker;
        RadDateTimePicker todt = RadWindow1.ContentContainer.FindControl("Rftodate") as RadDateTimePicker;


can some one please help me.
          

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 May 2012, 01:32 PM
Hi Phani,

After inspecting your code I found that you are using the incorrect id to access the RadDateTimePicker. Please try the following code snippet.

C#:
RadDateTimePicker fromdt = RadWindow1.ContentContainer.FindControl("DtFromdate") as RadDateTimePicker;
RadDateTimePicker todt = RadWindow1.ContentContainer.FindControl("DtTodate") as RadDateTimePicker;

Hope this helps.

Thanks,
Princy.
0
phani
Top achievements
Rank 1
answered on 30 May 2012, 08:28 AM
HI ,
Princy
sorry for typing wrongly.
iam using
        RadDateTimePicker fromdt = RadWindow1.ContentContainer.FindControl("DtFromdate") as RadDateTimePicker;
        DateTime dtfrom = fromdt.SelectedDate.Value;
        RadDateTimePicker todt = RadWindow1.ContentContainer.FindControl("DtTodate") as RadDateTimePicker;
        DateTime dtto = todt.SelectedDate.Value;
when the cursor passes dtfrom, it is raising an null exception.  
0
Marin Bratanov
Telerik team
answered on 01 Jun 2012, 01:26 PM
Hello,

Have you examined this onilne demo on accessing controls from the ContentTemplate of the RadWIndow: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx? It shows how you can access them on the server.

Nevertheless, for your convenience I am attaching here a sample page build on top of your code that uses the selected dates (you can see it in the attached video as well).  You can use this as base for your further development.


Kind regards,
Marin Bratanov
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
Ger Connery
Top achievements
Rank 1
answered on 08 Jun 2012, 01:39 PM
HI,
yes i have seen the onilne demos. 
The problem is i can not access the controls inside the content template of rad window from .cs page.


thank you,
phani.
0
Marin Bratanov
Telerik team
answered on 11 Jun 2012, 01:29 PM
Hi Phani,

Could you share the code you are using and that is not working? Have you taken a look at this help article that also explains how to access the controls inside the ContentTemplate? The RadWindow in this case is just an INaming container and does not require anything more then any other such container would, e.g. a placeholder in a master page scenario.


All the best,
Marin Bratanov
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
General Discussions
Asked by
phani
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
phani
Top achievements
Rank 1
Marin Bratanov
Telerik team
Ger Connery
Top achievements
Rank 1
Share this question
or