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

Creating Control with special features, How To

1 Answer 60 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 2
Bruno asked on 05 Mar 2009, 10:02 AM
Hi guys,

I need to create a control dynamically and used with this features

- Shows date and time like "dd-mm-yyyy hh:mm" [ DONE: using base.DateInput.DateFormat = "dd-MM-yyyy HH:mm"; ]
- Only shows one button icon (not the 2 buttons like RadDateTime) [ DONE: using RadDatePicker ]
- Shows the text as a label if the page (if the control is in a page) / row (if the control in in a Grid) is not in Edit mode [ Need help! ]

How can I do this?

Right now I'm doing:

 
    [DefaultProperty("Value")] 
    [ToolboxData("<{0}:MyOwnDateTimePicker runat=server></{0}:MyOwnDateTimePicker>")] 
    public class MyOwnDateTimePicker : Telerik.Web.UI.RadDatePicker 
    { 
        System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler; 
 
        protected override void Render(HtmlTextWriter writer) 
        { 
            /*
                <telerik:RadDatePicker ID="Raddatepicker2" Style="vertical-align: middle;" Width="200px"
                    MinDate="2006-02-01" runat="server" SelectedDate="2006-04-01" MaxDate="2099-12-16" Skin="Hay">
                    <DateInput onclick="ToggleSecondPopup()" DateFormat="D">
                    </DateInput>
                </telerik:RadDatePicker>
            */ 
 
            base.Skin = "Outlook"
            base.DateInput.DateFormat = "dd-MM-yyyy HH:mm"
 
            base.Render(writer); 
        } 
 
        public override void RenderControl(HtmlTextWriter writer) 
        { 
            // Bruno: Test 
            if (this.readOnly) 
            { 
                // Read-Only Calendar 
                // http://demos.telerik.com/aspnet-ajax/calendar/examples/functionality/readonlycalendar/defaultcs.aspx 
                // PresentationType="Preview", EnableNavigation="False" and EnableMonthYearFastNavigation="false" 
                base.Calendar.PresentationType = Telerik.Web.UI.Calendar.PresentationType.Preview; 
                base.Calendar.EnableNavigation = false
                base.Calendar.EnableMonthYearFastNavigation = false
 
                //Label lbl = new Label(); 
                //lbl.RenderControl(writer); 
            } 
            else 
            { 
               //Do nothing                  
            } 
            base.RenderControl(writer); 
        } 

How can I make the control to be ReadOnly? Showing only a "Label" like control?


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2009, 12:46 PM
Hi Bruno,

I tried the simple example of creating ReadOnly RadDatePicker dynamically. I hope the example shown below will give you some insight into the situation.

CS:
protected void Page_Load(object sender, EventArgs e) 
    RadDatePicker RadDatePicker11 = new RadDatePicker(); 
    RadDatePicker1.Skin = "Outlook"
    RadDatePicker1.DateInput.DateFormat = "dd-MM-yyyy HH:mm"
    RadDatePicker1.CssClass = "radInput_Outlook"
    RadDatePicker1.DateInput.ReadOnly = true
    this.form1.Controls.Add(RadDatePicker1); 

CSS:
<style type="text/css"
    .radInput_Outlook input 
    { 
        border:0 !important;  
        backgroundtransparent !important;                    
    } 
</style> 

Thanks,
Shinu.
Tags
Calendar
Asked by
Bruno
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or