Hello Folks
I am creating a web site and i have created a datepicker user control. i
have two instances of the the same control on my page and i want to use the
compair validation control to validate the data i have used created
validation property and try to set the control to validate property of
validation control but it did't appear in the dropdown then i tried to
hardcode the name of the control in the markup but it didn't work my code is
below can any one help me:
markup for user control:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile
="DateTimePicker.ascx.vb" Inherits="UserControls_DateTimePicker" %>
<asp:TextBox ID="DateTimeTextBox" runat="server" Width="184px"></asp:TextBox
>
<asp:ImageButton ID="CalenderImageButton" runat="server" ImageUrl
="~/images/downarrow.gif" />
<asp:Calendar id="UserCalendar"
runat="server" Height="176px" Width="104px" Font-Names="Verdana" Font-Size
="X-Small"
NextMonthText="HTML Text" NextPrevFormat= "ShortMonth" PrevMonthText="HTML
text" ForeColor="#000063" Visible="false">
<DayStyle ForeColor="Black" HorizontalAlign="Center" />
<NextPrevStyle Font-Names="Trebuchet MS" ForeColor="#000063" />
<DayHeaderStyle BackColor="#E0E0E0" Font-Names="Verdana" Font-Size="X-Small"
ForeColor="#000099" />
<TodayDayStyle BackColor="#999999" />
<OtherMonthDayStyle ForeColor="Gray" />
<TitleStyle BackColor="#999999" Font-Names="Verdana" Font-Size="X-Small"
Font-Underline="True" ForeColor="#000099" />
</asp:Calendar>
*User control code:*
<ValidationProperty("Value")> Partial Class UserControls_DateTimePicker
Inherits System.Web.UI.UserControl
Dim SelectedDate As Date
Public Event SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
Protected Sub CalenderImageButton_Click(ByVal sender As Object, ByVal
e AsSystem.Web.UI.ImageClickEventArgs)
Handles CalenderImageButton.Click
Me.UserCalendar.Visible = True
End Sub
Protected Sub UserCalendar_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles UserCalendar.SelectionChanged
Me.DateTimeTextBox.Text = Me.UserCalendar.SelectedDate
SelectedDate = Me.UserCalendar.SelectedDate
Me.UserCalendar.Visible = False
RaiseEvent SelectionChanged(sender, e)
End Sub
Public ReadOnly Property Value() As Date
Get
Return SelectedDate
End Get
End Property
End Class
*compair validator markup code:*
<asp:CompareValidator ID="CompareValidator3" runat="server"
ControlToCompare="DepartureDateTimePicker" ControlToValidate
="ReturnDateTimePicker"
Display="None" ErrorMessage="Date must be greater than today's date"
Operator="GreaterThanEqual" Type="Date">Date must be greater than today's
date</asp:CompareValidator>
if i set the ControlToCompare,ControlToValidate to the id of the user
control then validation didn't work but if i set the property to the text
box as:
ControlToCompare="DepartureDateTimePicker:DateTimeTextBox" ControlToValidate
="ReturnDateTimePicker:DateTimeTextBox"
it works but the problem is when the validation fails and i click on the
image button again to select another date it didn't display Calender
control. I am doing a ASP.NET course and i am not allowed to use third party
controls. so please help me.
thanks in advance.
Parminder