<script runat="server">
protected void Page_Init(object sender, EventArgs e)
{
if (Request.Form[CultureName.UniqueID] != null)
{
PageManager1.CultureName = Request.Form[CultureName.UniqueID];
PageManager1.TransferProperties();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Datetextbox1.DateValue = DateTime.Today;
Datetextbox2.DateValue = DateTime.Today;
Datetextbox3.DateValue = DateTime.Today;
Datetextbox4.DateValue = DateTime.Today;
Datetextbox5.DateValue = DateTime.Today;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DateTime vValue1 = Datetextbox1.DateValue;
DateTime vValue2 = Datetextbox2.DateValue;
DateTime vValue3 = Datetextbox3.DateValue;
DateTime vValue4 = Datetextbox4.DateValue;
DateTime vValue5 = Datetextbox5.DateValue;
CultureName.Value = DropDownList1.SelectedValue;
PageManager1.CultureName = CultureName.Value;
PageManager1.TransferProperties();
Datetextbox1.DateValue = vValue1;
Datetextbox2.DateValue = vValue2;
Datetextbox3.DateValue = vValue3;
Datetextbox4.DateValue = vValue4;
Datetextbox5.DateValue = vValue5;
}
</script>
<h2>DateFormat=Short, AllowMonthNames=Yes</h2>
You can type in the abbreviated month name. It will reformat to show the month number.<br/><br/>
<des:DateTextBox ID="Datetextbox1" runat="server" AllowMonthNames="Yes" />
<des:DataTypeCheckValidator ID="DataTypeCheckValidator1" runat="server"
ErrorMessage="Bad data" ControlIDToEvaluate="Datetextbox1"/>
<br/>
<br/>
<h2>DateFormat=Short, AllowMonthNames=Shows</h2>
You can type either month name or digits. It reformats to show the month abbreviated name.<br/><br/>
<des:DateTextBox ID="Datetextbox2" runat="server" AllowMonthNames="Show" />
<des:DataTypeCheckValidator ID="DataTypeCheckValidator2" runat="server" ErrorMessage="Bad data"
ControlIDToEvaluate="Datetextbox2"/>
<br/>
<br/>
<h2>DateFormat=Short, AllowMonthNames=Show+not uppercases</h2>
Normally the abbreviated month name is shown in uppercase. You can have it show in as defined in
CultureInfo by setting <span class="PropertyName">MonthNamesUppercase</span>="false"<br/><br/>
<des:DateTextBox ID="Datetextbox3" runat="server" AllowMonthNames="Show" MonthNamesUppercase="False" />
<des:DataTypeCheckValidator ID="DataTypeCheckValidator3" runat="server" ErrorMessage="Bad data"
ControlIDToEvaluate="Datetextbox3"/>
<br/>
<br/>
<h2>DateFormat=Abbreviated</h2>
<des:DateTextBox ID="Datetextbox4" runat="server" DateFormat="Abbreviated" />
<des:DataTypeCheckValidator ID="DataTypeCheckValidator4" runat="server" ErrorMessage="Bad data"
ControlIDToEvaluate="Datetextbox4"/>
<br/>
<br/>
<h2>DateFormat=Long</h2>
<des:DateTextBox ID="Datetextbox5" runat="server" DateFormat="Long"/>
<des:DataTypeCheckValidator ID="DataTypeCheckValidator5" runat="server" ErrorMessage="Bad data"
ControlIDToEvaluate="Datetextbox5"/>
<br/>
<br/>
<des:Button ID="Button1" runat="server"></des:Button><br/>
<br/>
Change the culture:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="en-US">en-US (United States)</asp:ListItem>
<asp:ListItem Value="en-GB">en-GB (Great Britain)</asp:ListItem>
<asp:ListItem Value="fr-CA">fr-CA (French in Canada)</asp:ListItem>
</asp:DropDownList>
<des:PageManager ID="PageManager1" runat="server" CultureName="en-US" />
<asp:HiddenField ID="CultureName" runat="server" Value="en-US" />