ASP.NET - Calendar Extender - Asked By Naresh Kumar on 30-Nov-10 02:13 AM

Hi All,

I am new to Ajax, I have an issue with Calendar Extender. After selecting the date in the popup I am not able to get the date in the text box . Below is my code and let me know where I went wrong:

<body>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">

<Triggers>

<asp:AsyncPostBackTrigger ControlID="UpdateButton2" EventName="Click" />

</Triggers>

<ContentTemplate>

<asp:Panel ID="pnlTest" runat="server" GroupingText="Tesing">

<table border="2">

<tr>

<td>

<asp:Label runat="server" ID="lblUser" Text="User :" />

</td>

<td>

<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvControls" runat="server" ErrorMessage="Enter UserName"

Display="None" ControlToValidate="txtUser" ValidationGroup="valControls"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td>

<asp:Label runat="server" ID="lblComp" Text="Company :" />

</td>

<td>

<asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvCompany" runat="server" ErrorMessage="Enter Company"

Display="None" ControlToValidate="txtCompany" ValidationGroup="valControls"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="revCompany" runat="server" ErrorMessage="Incorrect Company"

Display="None" ControlToValidate="txtCompany" ValidationGroup="valControls" ValidationExpression="^[a-zA-Z'.\s]{1,40}$"></asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td>

<asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>

</td>

<td>

<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>

<ajax:CalendarExtender ID="CalendarExtender2" runat="server" Enabled="True" Animated="false"

Format="MM/dd/yyyy" TargetControlID="txtStartDate">

</ajax:CalendarExtender>

<ajax:MaskedEditExtender ID="MaskedEditExtender4" runat="server" Mask="99/99/9999"

MaskType="Date" PromptCharacter="_" TargetControlID="txtStartDate">

</ajax:MaskedEditExtender>

</td>

</tr>

<tr>

<td>

<asp:Label runat="server" ID="lblCountry" Text="Country :" />

</td>

<td>

<asp:DropDownList ID="ddlCoun" runat="server">

</asp:DropDownList>

</td>

</tr>

<tr>

<td>

<asp:Button runat="server" ID="UpdateButton1" CausesValidation="true" ValidationGroup="valControls"

OnClick="UpdateButton_Click" Text="Update" />

</td>

</tr>

</table>

</asp:Panel>


<asp:ValidationSummary ID="valTest" runat="server" ShowMessageBox="false" ShowSummary="true"

ValidationGroup="valControls" />

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">

<ContentTemplate>

<asp:Panel ID="pnlTest2" runat="server" GroupingText="Testing2">

<table>

<tr>

<td>

<asp:Label runat="server" ID="DateTimeLabel2" />

<asp:Button runat="server" ID="UpdateButton2" OnClick="UpdateButton_Click" Text="Update" />

</td>

</tr>

</table>

</asp:Panel>

</ContentTemplate>

</asp:UpdatePanel>

</form>

</body>

SVK N replied to Naresh Kumar on 30-Nov-10 02:24 AM

<cc2:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="textbox1">

</cc2:CalendarExtender>



take a text box say textbox1 ina new page with CalendarExtender1.
there is no need to write any code for getting date in teh text box
thi shld work