tags:

views:

441

answers:

1

work on asp.net vs05. i want to set the system date as default value for the CalendarExtender in my textbox.In page load event if i write

textbox.text=datetime.now;

than it show error.if i click on CalendarExtender image icon to show calendar than it show an error message on status bar "error occurd" How to solve this problem?

 <asp:TextBox ID="txtFromDate" runat="server" Width="120px"></asp:TextBox></td>
                                                    <td style="width: 35px">
                                                        <img id="fromdate" src="Image/Calendar_scheduleHS.png" style="width: 18px" alt=""/></td>
                                                </tr>
                                            </table>
                                            <cc1:CalendarExtender
                                        ID="CalendarExtender2" runat="server" Format="dd MMM yyyy" PopupButtonID="fromdate"
                                        TargetControlID="txtFromDate">
                                    </cc1:CalendarExtender>
A: 

When setting txtFromDate.text from server side code you have to make sure the format is already correct.

Try

txtFromDate.Text = DateTime.Now.ToString("dd MMM yyyy");

or even better:

txtFromDate.Text = DateTime.Now.ToString(CalendarExtender2.Format);
Jared Coleson

related questions