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

Today button

8 Answers 172 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Udi
Top achievements
Rank 1
Udi asked on 26 Sep 2010, 08:32 PM
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

8 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 29 Sep 2010, 01:45 PM
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
0
Udi
Top achievements
Rank 1
answered on 29 Sep 2010, 02:50 PM
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
0
Iana Tsolova
Telerik team
answered on 30 Sep 2010, 10:57 AM
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
0
Udi
Top achievements
Rank 1
answered on 04 Oct 2010, 02:29 PM
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

0
Iana Tsolova
Telerik team
answered on 05 Oct 2010, 11:08 AM
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
0
Udi
Top achievements
Rank 1
answered on 05 Oct 2010, 02:01 PM
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
0
Udi
Top achievements
Rank 1
answered on 05 Oct 2010, 02:18 PM
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

0
Iana Tsolova
Telerik team
answered on 06 Oct 2010, 02:38 PM
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
Tags
Calendar
Asked by
Udi
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Udi
Top achievements
Rank 1
Share this question
or