I think I found the problem but not why. It has to do with the fact that
HTML comments don't seem to work with asp.net.
I have the following page:
********************************************************
<%@ Page Language="VB" trace="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" Inherits="MyFunctions.Page" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="MyFunctions" %>
<Script runat="server">
Sub Page_Load(s as Object, e as EventArgs)
Dim item as ListItem
Dim oLabel as Label
if not IsPostBack then
ValidateDate.ValueToCompare = DateTime.Today.ToString("yyyy-MM-dd")
end if
end sub
Sub SubmitNewHire_Click(s as Object, e as ImageClickEventArgs)
Dim pageError as Boolean = false
trace.warn("Before Page.IsValid if Page.IsValid = " & Page.IsValid & "
PageError = " & pageError)
If not Page.IsValid then
Exit Sub
End if
End Sub
</script>
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body id="myBody" runat="server">
<form runat="server">
<asp:TextBox ID="RequestedStartDate" Columns="12" runat="server"/>
<!-- <asp:CompareValidator runat="server" ID="ValidateDate"
ControlToValidate="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
Type="Date" text="<br>Invalid Start Date"/>
-->
<asp:ImageButton ImageUrl="../../buttons/submit_0.gif"
OnClick="SubmitNewHire_Click" runat="server"/>
</form>
</body>
</html>
*************************************************************
I should get an error here.
I have the Validator commented out but the line:
ValidateDate.ValueToCompare = DateTime.Today.ToString("yyyy-MM-dd")
Still seems to work. I should get an error that says that there is no such
object ValidateDate (as it is commented out). If I delete the Validator - I
get the error.
If I take out the ValidateDate.ValueToCompare line, I get an error saying
that '' is not a valid date. Why would I get that error if this Validator
is commented out? I get this error as I am entering the page.
This was why I was getting the error.
I was putting in yesterdays date (which the validator says I can't do). So
the page is showing as not valid. But since the Validator is commented
out - the error message doesn't show (which it does if I don't comment it
out).
What gives?
Thanks,
Tom