1

All respected, I have a Master detail project asp.net (sql data) project in which Master.aspx along with code behind page Master.aspx.cs. Following is the code:

<asp:TemplateField HeaderText="Date of Failure" SortExpression="Failure_date" >
<EditItemTemplate>
<asp:TextBox ID="EditFailure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox><img src="_images/images.jpg" style="margin-top:3px;width:30px;height:30px;cursor:hand;" onclick="PopupPicker('EditFailure_date')" />  
<asp:RequiredFieldValidator ID="Failure_dateRequiredFieldValidator" runat="server" ControlToValidate="EditFailure_date" Display="Dynamic"  ErrorMessage="Can not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Failure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:dd/MM/yyyy}") %>'  ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

Now I want to add a popup calender for above text box 'EditFailure_date' without codebehind. Please help.

user1235981
  • 21
  • 2
  • 7

2 Answers2

0
 <asp:TextBox ID="txtDOJ" Text='<%# Bind("DOJ", "{0:dd-MMM-yyyy}") %>'                                                                                                runat="server" class="form-control input-sm m-bot15" BackColor="#cbeddc"></asp:TextBox>                                                                                            <asp:CalendarExtender ID="CalExtender" runat="server" Enabled="true" Format="dd-MMM-yyyy"                                                                                       TargetControlID="txtDOJ">                                                                                           </asp:CalendarExtender>
Code
  • 679
  • 5
  • 9
0

You can use the AjaxControlToolkit's calendar like this:

<asp:TextBox ID="EditFailure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox>
<ajaxToolkit:CalendarExtender runat="server" ID="cal_EditFailure_date" TargetControlID="EditFailure_date" /> 

Edit: You can also use a jquery solution such as the jQueryUI DatePicker

Josh Mein
  • 28,107
  • 15
  • 76
  • 87
  • @user1235981 Your welcome! If this was exactly what you needed, please mark the answer as accepted. Otherwise, feel free to update your question with a little more information. Welcome to Stackoverflow! – Josh Mein Feb 29 '12 at 13:11