Click here to Skip to main content
15,878,231 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
datePicker.ascx
<asp:TextBox ID="txtDatePicker" runat="server"></asp:TextBox> 
    <asp:ImageButton runat="Server" ID="Image1" ImageUrl="~/Images/calendar.png" AlternateText="Click to show calendar" /> 
    <ajaxToolkit:CalendarExtender Format="dd/MM/yyyy" ID="CalendarExtender1" TargetControlID="txtDatePicker"  runat="server" PopupButtonID="Image1" />

register.aspx
<%@ Register Src="~/Modules/datePicker.ascx" TagName ="datePicker" TagPrefix ="uc1"  %>
Start Date   <uc1:datePicker ID="datePickerSD"  runat="server" >
End Date     <uc1:datePicker ID="datePickerED"  runat="server" />
 <asp:CustomValidator  ID="CustomValidator1"  ControlToValidate="datePickerED"
                      ErrorMessage="End date should be greater than start date" runat="server"


How to get clientid of datePickerSD?
Posted
Comments
TheKarateKid 25-Feb-15 9:02am    
How you are validating the Start Date and End Date, are you validating using JavaScript/CustomValidator? Where is that function written in register.aspx ?
If you are using JavaScript the you can get the id of a control by <%= datePickerSD.ClientID %> to get the Client ID
If you are using jQuery then you can use jQuery selector like $('#[id$=_datePickerSD]'); to get the control and so on
What have you tried?
Member 9018012 26-Feb-15 5:29am    
I try to get clientId but not working...

1 solution

Solved:
<asp:comparevalidator id="compareValidatorDate" runat="server" controltovalidate="datePickerED$txtDatePicker" controltocompare="datePickerSD$txtDatePicker" cultureinvariantvalues="true" xmlns:asp="#unknown">
                                           ErrorMessage="End date should be greater than start date" Operator="GreaterThanEqual" SetFocusOnError="false" Type="String" Display="Dynamic" EnableClientScript="true" Font-Size="Small" ForeColor="Red"></asp:comparevalidator>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900