Today button

9 posts, 0 answers
  1. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 26 Sep 2010 Link to this post

    Hi,

    I would like to wrap the RadCalender and make MyRadCalender server control.
    Actually, i need to add  the Today button as a default when i create an instance of the control.
    I searched your forums and i found this code:

        function GoToToday() { 
            var datepicker = $find("<%=RadDatePicker10.ClientID%>"); 
            var dt = new Date(); 
            datepicker.set_selectedDate(dt); 
        } 

        <telerik:RadDatePicker ID="RadDatePicker10" runat="server" Width="140px"
            <Calendar runat="server"
                <FooterTemplate> 
                    <div style="width: 100%; text-align: center; background-color: Gray;"
                        <input id="Button1" type="button" value="Today" onclick="GoToToday()" /> 
                    </div> 
                </FooterTemplate> 
            </Calendar> 
        </telerik:RadDatePicker> 
    Actually, this is the result i need, but i need it as a default and not to write the code in the client side every time someone uses the control.
    I know i need to override the render method  somehow in my wraped server control.
    Can you give a small example how to do it?

    Thank you
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 29 Sep 2010 Link to this post

    Hello Oren,

    In order to achieve your goal, you can create a WebUserControl which to be reused over the web application. Another option is to create a control inheriting from WebControl or implementing the INamingContainer container. And instantiate the modified data picker there. To register the custom javascript you have, you can use the ScriptManager.RegisterStartupScript() method.

    Greetings,
    Iana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post

    Hi lana,

    Thanks for yor replay.

    My idea was to create a server control inheriting from the RadDatePicker control that for to achieve all the Rad advantags.
    something like:

        public class MyPicker : RadDatePicker
       {
          ...
            //Set default to the control...
         ...
         //Here i want to write the code that rendering the page like the folowing example :
     ... 
      
      
             //Here need  to render to the html page       
                        
                   
          
      
    ...   
       } 
      My problem is to understand how to render it like the following example:
    A calender below the datepicker and above the FooterTemplate etc.

     ... <telerik:RadDatePicker ID="RadDatePicker10" runat="server" Width="140px"
            <Calendar runat="server"
                <FooterTemplate> 
                    <div style="width: 100%; text-align: center; background-color: Gray;"
                        <input id="Button1" type="button" value="Today" onclick="GoToToday()" /> 
                    </div> 
                </FooterTemplate> 
            </Calendar> 
        </telerik:RadDatePicker> 

    Regarding the additional javascript i know to handle it.
    I dont intresting at a Web user control only at a server control that warp your Rad control.

    Thank you,
    Oren
  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 30 Sep 2010 Link to this post

    Hi Oren,

    If your class inherits from RadDatePicker, try overriding this.Calendar.FooterTemplate property.

    Best wishes,
    Iana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 04 Oct 2010 Link to this post

    Hello,

    I would like to add a footer template to a calendar control and then to add the new calendar,
    to a RadDatePicker control.
    i need to do it in the code behind (not in the aspx page).
    My problem is to combine between the calendar control and the datepicker control in the code behind.

    example:
    the following code i would like to pass to the code behind:

     

    <telerik:RadDatePicker ID="RadDatePicker10" runat="server" Width="140px" Skin="Forest"> 

     

                <Calendar ID="Calendar1" runat="server" Skin="Forest">

     

                    <HeaderTemplate>

     

                        <div style="width: 100%; text-align: center; background-color: white;" >

     

                            <input id="Button1" type="button" value="Today" onclick="GoToToday()" />

     

                        </div>

     

                    </HeaderTemplate>  

     

                </Calendar>

     

    </telerik:RadDatePicker>

    Thank you,
    Oren

  6. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 05 Oct 2010 Link to this post

    Hello Oren,

    You can create custom RadDatePicker control and override its Calendar.FooterTemplate or Calendar.HeaderTemplate property.

    Sincerely yours,
    Iana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 05 Oct 2010 Link to this post

    Hi lana,

    I'm sorry but i can't find this override (Calender.FooterTemplate) in RadDatePicker control.
    i'm looking at the metadata file of this control and there is only "Calender" property that i can override and it has only getter option.(no setter).
    I'm using controls version ASP.NET_AJAX_2010_1_519 (with Licence).
    Is that the problem?

    Regard,
    Oren
  8. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 05 Oct 2010 Link to this post

    Hi lana,

    At the end i succeded to handle that.

    the solution is:

     

    public override RadCalendar Calendar

     

    {

     

        get

     

        {

     

            //return base.Calendar;

     

     

            return (RadCalendar)MyCal;

     

        }

    }

    "MyCal" is a Calender that contain the footer template.

    Thank you,
    Oren

  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 06 Oct 2010 Link to this post

    Hi Oren,

    I am glad to know you were able to find a resolution for your case. Also sharing it here is great of you as this might help to other community members for their cases.

    All the best,
    Iana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top