How to set the WebInput to show Date data based on the specified culture?

2 replies. Last post: December 8, 2010 3:04 PM by Shawn August
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Shawn AugustMember

I have a WebInput that I am using to allow the user to specify a Date object.  I am using the WebInput's CultureInfo.CultureName to specify the culture:

this.wiTransHeaderSettlementDue.CultureInfo.CultureName = "en-GB";

How do you set the WebInput to show the Date data based on the specified culture both on the server-side and the culture side? For the server-side, the WebInput's Value property seems to work assuming you provide a .NET DateTime object instead of in string representation:

For example, the following shows "06-Dec-2010"

this.wiTransHeaderSettlementDue.Value = DateTime.Now

where as the following shows "12-Jun-2010" which is incorrect (Therefore, the .NET DateTime object should be used instead of this):

this.wiTransHeaderSettlementDue.Value = DateTime.Now.ToString()

However, how is this done on the JavaScript? When the same approach is made on the client-side, the incorrect "12-Jun-2010" is displayed which is incorrect. How do you fix this?

wiTransHeaderSettlementDue.SetValueData(new Date());
<ISWebInput:WebInput runat="server" ID="wiTransHeaderSettlementDue" Width="100px" CausesValidation="false">
                                                    <EditFormat>
                                                        <ErrorWindowStyle ForeColor="Red"></ErrorWindowStyle>
                                                    </EditFormat>
                                                    <FrameStyle>
                                                        <Normal BackColor="White" BorderColor="#E0E0E0" BorderStyle="Solid" BorderWidth="1px" Height="100%"></Normal>
                                                        <Over BackColor="WhiteSmoke" BaseStyle="Normal" BorderColor="MidnightBlue" BorderStyle="Solid" BorderWidth="1px"></Over>
                                                        <Active BackColor="White" BaseStyle="Over"></Active>
                                                    </FrameStyle>
                                                    <DateTimeEditor IsEnabled="True">
                                                        <DateTimeStyle BorderColor="MidnightBlue" BorderStyle="Solid" BorderWidth="1px" Height="140px" Width="200px"></DateTimeStyle>
                                                        <DayStyle>
                                                            <Normal Cursor="Hand" Font-Names="Arial" Font-Size="10px"></Normal>
                                                            <Over BackColor="DarkOrange" BaseStyle="Normal" Cursor="Hand" Font-Names="Arial" Font-Size="10px"></Over>
                                                            <Active BackColor="RoyalBlue" BaseStyle="Over" Cursor="Hand" Font-Names="Arial" Font-Size="10px"></Active>
                                                        </DayStyle>
                                                        <OtherMonthDayStyle Cursor="Hand" Font-Names="Arial" Font-Size="10px" ForeColor="Silver" />
                                                        <HeaderDayStyle Font-Bold="True" Font-Names="Arial" Font-Size="11px"></HeaderDayStyle>
                                                        <HighLightMonthYearStyle BackColor="Gainsboro" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True"></HighLightMonthYearStyle>
                                                        <DropDownMonthYearTextStyle Cursor="Hand" Font-Names="Arial" Font-Size="10px"></DropDownMonthYearTextStyle>
                                                        <DropDownMonthYearHighLightTextStyle BackColor="WhiteSmoke" Cursor="Hand" Font-Names="Arial" Font-Size="10px"></DropDownMonthYearHighLightTextStyle>
                                                        <DropDownMonthYearUpDownButtonStyle BackColor="#FFD294" Cursor="Hand" Font-Names="Arial" Font-Size="10px"></DropDownMonthYearUpDownButtonStyle>
                                                        <HeaderStyle BackColor="DarkOrange" BackColor2="255, 210, 148" Font-Bold="True" Font-Names="Arial" Font-Size="10pt" GradientType="Vertical" Height="24px" />
                                                        <FooterStyle BackColor="#FFF2C8" Font-Bold="True" Font-Names="Arial" Font-Size="11px" Height="20px" />
                                                        <DayOffStyle Font-Bold="True" Font-Names="Arial" Font-Size="11px" ForeColor="Red" Height="20px"></DayOffStyle>
                                                        <HolidayStyle BackColor="WhiteSmoke" Font-Bold="True" Font-Names="Arial" Font-Size="11px" ForeColor="Red" Height="20px"></HolidayStyle>
                                                        <WindowInfo DisplayType="Normal"></WindowInfo>
                                                    </DateTimeEditor>          
                                                    <CultureInfo CultureName="en-US"></CultureInfo>
                                                    <DisplayFormat Format="dd-MMM-yyyy" IsEnabled="True" />
                                                    <DropDownStyle>
                                                        <Normal Cursor="Hand" CssClass="WebInputDropDownStyleNormal"></Normal>
                                                        <Over BaseStyle="Normal" Cursor="Hand" CssClass="WebInputDropDownStyleOver"></Over>
                                                        <Active BaseStyle="Normal"></Active>
                                                    </DropDownStyle>
                                                    <CalculatorEditor>
                                                            <CalculatorStyle BackColor="DarkOrange" BackColor2="255, 210, 148" BorderColor="MidnightBlue"
                                                                BorderStyle="Solid" BorderWidth="1px" Font-Names="Arial" Font-Size="12px" ForeColor="MidnightBlue"
                                                                GradientType="Vertical" Height="150px" Overflow="Hidden" OverflowX="Hidden" OverflowY="Hidden"
                                                                Width="150px">
                                                            </CalculatorStyle>
                                                            <OperandStyle>
                                                                <Normal BackColor="#FFD294" BorderColor="White" BorderStyle="Solid" BorderWidth="1px"
                                                                    Cursor="Hand">
                                                                </Normal>
                                                                <Over BackColor="White" BackColor2="255, 210, 148" BaseStyle="Normal" Cursor="Hand"
                                                                    GradientType="Vertical">
                                                                </Over>
                                                                <Active BackColor="DarkOrange" BackColor2="255, 210, 148" BaseStyle="Over" Cursor="Hand">
                                                                </Active>
                                                            </OperandStyle>
                                                            <OperatorStyle>
                                                                <Normal BackColor="#FFD294" BorderColor="White" BorderStyle="Solid" BorderWidth="1px"
                                                                    Cursor="Hand">
                                                                </Normal>
                                                                <Over BackColor="White" BackColor2="255, 210, 148" BaseStyle="Normal" Cursor="Hand"
                                                                    GradientType="Vertical">
                                                                </Over>
                                                                <Active BackColor="DarkOrange" BackColor2="255, 210, 148" BaseStyle="Over" Cursor="Hand">
                                                                </Active>
                                                            </OperatorStyle>
                                                            <WindowInfo DisplayType="Normal">
                                                            </WindowInfo>
                                                        </CalculatorEditor>
                                                </ISWebInput:WebInput>
All times are GMT -5. The time now is 6:43 PM.
Previous Next