Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > OK button doesn't work properly with multiple validator controls

Reply
Thread Tools

OK button doesn't work properly with multiple validator controls

 
 
Sally
Guest
Posts: n/a
 
      10-18-2005
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 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!

 
Reply With Quote
 
 
 
 
Sally
Guest
Posts: n/a
 
      10-19-2005

Sally wrote:
> 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 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!


 
Reply With Quote
 
 
 
 
Sally
Guest
Posts: n/a
 
      10-19-2005
On further investigation it appears that the problem is due to IIS
configuration issue on my machine. This same code works fine on other
machines. I'm not sure what exactly is misconfigured, but will
investigate further.


Sally wrote:
> 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 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!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range Validator Does Not Work Properly Joey ASP .Net 3 08-08-2005 02:39 PM
Multiple user controls not reloading properly Mark ASP .Net 4 05-23-2005 09:03 AM
validator controls and disabled controls =?Utf-8?B?RHVuZQ==?= ASP .Net 2 02-04-2004 08:27 PM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM
Server Controls don't work properly Uriy leyfm ASP .Net 1 07-30-2003 03:53 AM



Advertisments