Validation Summary not showing for client side validation

  • Thread starter Thread starter cwhankey
  • Start date Start date
C

cwhankey

When I enter a non-date in the text box of the sample page show below
and then tab off, the red * shows next to the text box. However, the
error message does not show up in the validation summary until I click
the button. Is there a way that I can get the validation summary to
display the error message when I tab off of the text box?



<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3"
EnableEventValidation="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />&nbsp;
<asp:TextBox ID="TextBox1" runat="server"
CausesValidation="True"></asp:TextBox>&nbsp;&nbsp;
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToValidate="TextBox1"
ErrorMessage="value not a date" Operator="DataTypeCheck"
</div>
</form>
</body>
</html>
 
this by design. the validation own message span is updated on lost
focus. the validation summary is only updated at start of postback. if
you look at the validation client code, you'll see its pretty simple. i
tried this once, and the visual effect wasn't the best. plus you really
need to run all the validators.

note: the code is not structured very well for modification, so you will
need to duplicate code.

-- bruce (sqlwork.com)
 
Back
Top