Creating Control with special features, How To

2 posts, 0 answers
  1. Bruno
    Bruno avatar
    11 posts
    Member since:
    Jan 2009

    Posted 05 Mar 2009 Link to this post

    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:

        [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">
                base.Skin = "Outlook"
                base.DateInput.DateFormat = "dd-MM-yyyy HH:mm"
            public override void RenderControl(HtmlTextWriter writer) 
                // Bruno: Test 
                if (this.readOnly) 
                    // Read-Only Calendar 
                    // 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(); 
                   //Do nothing                  

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

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2009 Link to this post

    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.

    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

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

  3. DevCraft R3 2016 release webinar banner
Back to Top