Reputation: 21
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.
Upvotes: 1
Views: 6516
Reputation: 739
<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>
Upvotes: 0
Reputation: 28645
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
Upvotes: 0