S
Sally
I've created an ASPX page with 2 textboxes and an OK button. The 2
textboxes each have 2 validator controls, a RequiredFieldValidator and
a CustomValidator. Both CustomValidator controls link to JavaScript
validate methods at the top of the ASPX file (HTML view).
With only 1 textbox and its pair of validator controls, the OK button
works properly (it displays a status message in a label).
However, with the 2 sets of textboxes and associated validator
controls, the OK button no longer works. No postback occurs when you
click on it.
The full text of my ASPX file is as follows:
<%@ Page language="c#" Codebehind="Test.aspx.cs"
AutoEventWireup="false" Inherits="RecorderLight.Test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Test</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
function ValidateEmail(source, arguments)
{
if (arguments.Value == "(e-mail address removed)")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
function ValidateUsername(source, arguments)
{
if (arguments.Value == "sally.revell")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table style="WIDTH: 632px; HEIGHT: 208px" borderColor="black"
border="1">
<tr height="20%">
<td align="center" colSpan="3">Table Title</td>
</tr>
</TR>
<tr height="40%">
<td width="20%"><asp:label id="lblEmail"
runat="server">Email:</asp:label></td>
<td width="40%"><asp:textbox id="txtEmail"
runat="server"></asp:textbox></td>
<td width="40%"><asp:requiredfieldvalidator
id="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="txtEmail"
EnableClientScript="False"></asp:requiredfieldvalidator><asp:customvalidator
id="CustomValidator1" runat="server" ErrorMessage="Email must be
unique" ControlToValidate="txtEmail"
ClientValidationFunction="ValidateEmail"
Display="Dynamic"></asp:customvalidator></td>
</tr>
<tr height="40%">
<td width="20%"><asp:label id="lblUsername"
runat="server">Username:</asp:label></td>
<td width="40%"><asp:textbox id="txtUsername"
runat="server"></asp:textbox></td>
<td width="40%"><asp:requiredfieldvalidator
id="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="txtUsername"
EnableClientScript="False"></asp:requiredfieldvalidator><asp:customvalidator
id="CustomValidator2" runat="server" ErrorMessage="Username must be
unique" ControlToValidate="txtUsername"
ClientValidationFunction="ValidateUsername"
Display="Dynamic"></asp:customvalidator></td>
</tr>
<tr height="40%">
<td align="center" colSpan="3"><asp:imagebutton id="ImageButton1"
runat="server" ImageUrl="images/Ok.gif"></asp:imagebutton></td>
</tr>
</table>
<asp:label id="lblStatus" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 240px"
runat="server" Width="392px"></asp:label></form>
</body>
</HTML>
And here is button click event handler from the C# code behind file:
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid == true)
{
lblStatus.Text = "Page is Valid!";
}
else
{
lblStatus.Text = "Some of the required fields are empty";
}
}
Has anyone else come across this, and, if so, do you know a fix?
Thanks very much!
textboxes each have 2 validator controls, a RequiredFieldValidator and
a CustomValidator. Both CustomValidator controls link to JavaScript
validate methods at the top of the ASPX file (HTML view).
With only 1 textbox and its pair of validator controls, the OK button
works properly (it displays a status message in a label).
However, with the 2 sets of textboxes and associated validator
controls, the OK button no longer works. No postback occurs when you
click on it.
The full text of my ASPX file is as follows:
<%@ Page language="c#" Codebehind="Test.aspx.cs"
AutoEventWireup="false" Inherits="RecorderLight.Test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Test</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
function ValidateEmail(source, arguments)
{
if (arguments.Value == "(e-mail address removed)")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
function ValidateUsername(source, arguments)
{
if (arguments.Value == "sally.revell")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table style="WIDTH: 632px; HEIGHT: 208px" borderColor="black"
border="1">
<tr height="20%">
<td align="center" colSpan="3">Table Title</td>
</tr>
</TR>
<tr height="40%">
<td width="20%"><asp:label id="lblEmail"
runat="server">Email:</asp:label></td>
<td width="40%"><asp:textbox id="txtEmail"
runat="server"></asp:textbox></td>
<td width="40%"><asp:requiredfieldvalidator
id="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="txtEmail"
EnableClientScript="False"></asp:requiredfieldvalidator><asp:customvalidator
id="CustomValidator1" runat="server" ErrorMessage="Email must be
unique" ControlToValidate="txtEmail"
ClientValidationFunction="ValidateEmail"
Display="Dynamic"></asp:customvalidator></td>
</tr>
<tr height="40%">
<td width="20%"><asp:label id="lblUsername"
runat="server">Username:</asp:label></td>
<td width="40%"><asp:textbox id="txtUsername"
runat="server"></asp:textbox></td>
<td width="40%"><asp:requiredfieldvalidator
id="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="txtUsername"
EnableClientScript="False"></asp:requiredfieldvalidator><asp:customvalidator
id="CustomValidator2" runat="server" ErrorMessage="Username must be
unique" ControlToValidate="txtUsername"
ClientValidationFunction="ValidateUsername"
Display="Dynamic"></asp:customvalidator></td>
</tr>
<tr height="40%">
<td align="center" colSpan="3"><asp:imagebutton id="ImageButton1"
runat="server" ImageUrl="images/Ok.gif"></asp:imagebutton></td>
</tr>
</table>
<asp:label id="lblStatus" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 240px"
runat="server" Width="392px"></asp:label></form>
</body>
</HTML>
And here is button click event handler from the C# code behind file:
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid == true)
{
lblStatus.Text = "Page is Valid!";
}
else
{
lblStatus.Text = "Some of the required fields are empty";
}
}
Has anyone else come across this, and, if so, do you know a fix?
Thanks very much!