How to get the values of Rad Window ContentTemplate

6 posts, 0 answers
  1. phani
    phani avatar
    6 posts
    Member since:
    May 2011

    Posted 29 May 2012 Link to this post

    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.
              
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 May 2012 Link to this post

    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.
  3. phani
    phani avatar
    6 posts
    Member since:
    May 2011

    Posted 30 May 2012 Link to this post

    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.  
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4568 posts

    Posted 01 Jun 2012 Link to this post

    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.
  5. Ger Connery
    Ger Connery avatar
    1 posts
    Member since:
    Feb 2010

    Posted 08 Jun 2012 Link to this post

    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.
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4568 posts

    Posted 11 Jun 2012 Link to this post

    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.
Back to Top