Validation Summary not showing for client side validation

Discussion in 'ASP .Net' started by cwhankey@gmail.com, Dec 12, 2008.

  1. Guest

    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"
    Type="Date">*</asp:CompareValidator><br />
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" /
    >

    </div>
    </form>
    </body>
    </html>
     
    , Dec 12, 2008
    #1
    1. Advertising

  2. bruce barker Guest

    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)

    wrote:
    > 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"
    > Type="Date">*</asp:CompareValidator><br />
    > <asp:ValidationSummary ID="ValidationSummary1" runat="server" /
    > </div>
    > </form>
    > </body>
    > </html>
     
    bruce barker, Dec 12, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Libs
    Replies:
    0
    Views:
    1,508
  2. Matt
    Replies:
    14
    Views:
    4,114
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  3. =?Utf-8?B?dmlkeWE=?=
    Replies:
    1
    Views:
    758
    Kevin Spencer
    Jun 2, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,061
    Boss302
    Nov 21, 2006
  5. Bogdan
    Replies:
    2
    Views:
    658
    Bogdan
    Jun 9, 2008
Loading...

Share This Page