1

I hvae a textbox and image button.upon clicking image button , the calendarextender will appear and the selected date from calendarextender should be populated in the textbox.but date is not populated.please guide me to fix this issue.

Here is my code

<asp:TextBox ID="txtAccidentDate" MaxLength="10" Text=""
     runat="server" SkinID="ClaimTextBox" Width="80px" TabIndex="1" />

<cc1:MaskedEditExtender ID="MaskedEditExtender2" runat="server" 
      TargetControlID="txtAccidentDate" Mask="99/99/9999"
      MessageValidatorTip="false" MaskType="Date"
      DisplayMoney="Left" AcceptNegative="Left"
      ErrorTooltipEnabled="True" />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
     runat="server" ControlToValidate="txtAccidentDate" 
     Display="None" 
     ErrorMessage="Please select Accident Date" 
      ValidationGroup="Insured" SetFocusOnError="true">
</asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
     runat="server" ControlToValidate="txtAccidentDate"
     ValidationGroup="Insured" Display="None"
     ErrorMessage="Please Enter valid Date" 
     SetFocusOnError="true"
     ValidationExpression="(((0?[1-9]|1[012])[/.](0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])[/.](29|30)|(0?[13578]|1[02])/31)[/.](19|[2-9]\d)\d{2}|0?2[/.]29[/.]((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))">
</asp:RegularExpressionValidator>

<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" 
     runat="server" Enabled="True"
     TargetControlID="RegularExpressionValidator2">
</cc1:ValidatorCalloutExtender>

<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender6"
     runat="server" Enabled="True" 
     TargetControlID="RequiredFieldValidator1">
</cc1:ValidatorCalloutExtender>

<cc1:CalendarExtender ID="CalendarExtender2" 
     runat="server" Enabled="True"
     PopupButtonID="imgcal" Format="MM/dd/yyyy"
     TargetControlID="txtAccidentDate" />

<asp:ImageButton ID="imgcal" runat="server" CausesValidation="false" 
     ImageUrl="~/Images/Calendar_scheduleHS.png" /> 

<span class="helpInformantion">(mm/dd/yyyy)</span> 
Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62
senthilstayss
  • 11
  • 1
  • 6
  • Could you please try without MaskedEditExtender control on the textbox. I remember some time I ago I faced similar issue where a MaskedEditExtender control conflicting with CalendarExtender. – Puneet Khurana Mar 13 '14 at 06:31
  • Check this link also http://stackoverflow.com/questions/5463258/using-a-calendarextender-with-a-maskededitextender – Puneet Khurana Mar 13 '14 at 06:37

2 Answers2

0

I think you have used ScriptManager right. Just use ToolScriptManager Instead of ScriptManager

i.e.,

Change This

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

to

 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

Try this code

 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
        <asp:TextBox ID="txtAccidentDate" MaxLength="10" Text="" runat="server" SkinID="ClaimTextBox" Width="80px" TabIndex="1" />

        <asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="txtAccidentDate" 
            Mask="99/99/9999" MessageValidatorTip="false" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left" ErrorTooltipEnabled="True" />

      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtAccidentDate"
            Display="None" ErrorMessage="Please select  Accident Date" ValidationGroup="Insured"
            SetFocusOnError="true">
        </asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtAccidentDate"
            ValidationGroup="Insured" Display="None" ErrorMessage="Please Enter valid Date"
            SetFocusOnError="true" ValidationExpression="(((0?[1-9]|1[012])[/.](0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])[/.](29|30)|(0?[13578]|1[02])/31)[/.](19|[2-9]\d)\d{2}|0?2[/.]29[/.]((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))">
        </asp:RegularExpressionValidator>
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" runat="server" Enabled="True"
            TargetControlID="RegularExpressionValidator1">
                                        </asp:ValidatorCalloutExtender>
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender6" runat="server" Enabled="True"
            TargetControlID="RequiredFieldValidator1">
                                        </asp:ValidatorCalloutExtender>
        <asp:CalendarExtender ID="CalendarExtender2" runat="server" Enabled="True" PopupButtonID="imgcal"
            format="MM/dd/yyyy" TargetControlID="txtAccidentDate" />
        <asp:ImageButton ID="imgcal" runat="server" CausesValidation="false" ImageUrl="~/Images/Calendar.png" />
        <span class="helpInformantion">(mm/dd/yyyy)</span>
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
  • @senthilstayss Copy my above code and try this instead of your code – Vignesh Kumar A Mar 14 '14 at 03:14
  • I have tried your code also.it says ToolScript manager is not a known element.But when i add .It doesn't show any warning but not working.did i miss aything to install ? Thanks in advance.. – senthilstayss Mar 14 '14 at 04:12
  • Which version of Ajax ToolKir are you using? – Vignesh Kumar A Mar 14 '14 at 04:25
  • ajax control tool kit 3.0.30512.0 – senthilstayss Mar 14 '14 at 04:29
  • Please use the Latest version of Ajax Tool kit... Link here https://ajaxcontroltoolkit.codeplex.com/releases/view/116091 – Vignesh Kumar A Mar 14 '14 at 05:00
  • I tried to install the latest version.I have vs 2010 installed on my system. got the following error. Error 99 (0): error CS1705: Assembly 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' uses 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' – senthilstayss Mar 15 '14 at 03:10
  • @senthilstayss Check this link http://stackoverflow.com/questions/9219832/error-cs1705-which-has-a-higher-version-than-referenced-assembly – Vignesh Kumar A Mar 15 '14 at 03:14
  • This is how only my web.config looks like. – senthilstayss Mar 15 '14 at 03:59
0

You have to write the code to set the of selected calender date to text box. you can do this by writing code on calender's SelectionChanged Event

Your code should look like

 protected void calendarextender_SelectionChanged(object sender, EventArgs e)
 {
   txtAccidentDate.text = calendarextender.SelectedDate;
 }

Here calender extender is the id of your extender.

Akki
  • 121
  • 5