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

RadDatePicker Q1 2012 static width when setting SelectedDate via codebehind

1 Answer 130 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 08 Mar 2012, 05:17 PM

I have a problem with setting the width of an RadDatePicker contro and set the SelectedDate property via the codebehind.
Her is my sample code APSX:

<telerik:RadDatePicker ID="DatePicker1" runat="server" Width="30px" AutoPostBack="true">
<Calendar CultureInfo="en-US" FirstDayOfWeek="Monday" ID="Calendar1" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x" runat="server"/>
<DateInput ID="DateInputFrom" DateFormat="dd.MM.yyyy" DisplayDateFormat="dd.MM.yyyy" runat="server"/>
</telerik:RadDatePicker>

And here the Codebhind:

protected void Page_Load(object sender, EventArgs e)
{
DatePicker1.SelectedDate = DateTime.Now;
}

Is there any workaround to set the correct Width?

 

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 12 Mar 2012, 10:00 PM
Florian:

I copied over your code and ran it. By simply changing the property setting for the RadDatePicker to "Width="100px" the full date displays correctly. I believe that this width setting takes in the entire width of the component, textbox and popup calendar combined.

Default.aspx:
<telerik:RadDatePicker ID="DatePicker1" runat="server" Width="100px" AutoPostBack="true">
    <calendar cultureinfo="en-US" firstdayofweek="Monday" id="Calendar1" usecolumnheadersasselectors="False"
        userowheadersasselectors="False" viewselectortext="x" runat="server" />
    <dateinput id="DateInputFrom" dateformat="dd.MM.yyyy" displaydateformat="dd.MM.yyyy"
        runat="server" />
</telerik:RadDatePicker>

Alternatively, you can remove the width setting from the RadDatePicker definition and set it as a property of the dateinput textbox:

Default.aspx:
<telerik:RadDatePicker ID="DatePicker1" runat="server" AutoPostBack="true">
    <calendar cultureinfo="en-US" firstdayofweek="Monday" id="Calendar1" usecolumnheadersasselectors="False"
        userowheadersasselectors="False" viewselectortext="x" runat="server" />
    <dateinput id="DateInputFrom" dateformat="dd.MM.yyyy" displaydateformat="dd.MM.yyyy" Width="30px"
        runat="server" />
</telerik:RadDatePicker>

The latter works better and the "30px" assignment displays the full date.

Regards,
Tags
Calendar
Asked by
Florian
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or