Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to not show BaseValidator.Text when using a ValidationSummary in ASP.NET
    primarykey
    data
    text
    <p>I'm using a bunch of different asp.net validation controls on a web form. Some of these have their Text property set to things like "* Error" or "You missed these fields". </p> <p>However, a few of the CustomValidator controls have blank Text properties. I left them blank on purpose because I'm adding the ErrorMessage dynamically depending on which case fails. (A CustomValidator may have many different conditions upon which I set args.IsValid = false)</p> <p>When an error occurs, the ErrorMessage property that I set is shown both in the ValidationSummary and inside the Validator control. I don't want that. I want to be able to <b>just show the ErrorMessage in the ValidationSummary and not in the BaseValidator.Text property.</b></p> <p>My first try was to set the Text property to be a space " ". That didn't work.</p> <p>What I implemented (for now) is a period that is shown as the same color of the background. It's a hack - and I don't like it. Heck, maybe that's why I'm here!</p> <p>Here's the code:</p> <pre><code>&lt;asp:CustomValidator ID="StackOverflowValidator" runat="server" Text="." CssClass="validatorstyle" Display="Dynamic" OnServerValidate="validate_AllowedToDoSomething" ValidationGroup="MainGroup" /&gt; &lt;asp:ValidationSummary ID="mainGroupValidationSummary" runat="server" ValidationGroup="MainGroup" DisplayMode="BulletList" HeaderText="There was an error in saving. Please check the following:" /&gt; </code></pre> <p>Inside validate_AllowedToDoSomething I call:</p> <pre><code>StackOverflowValidator.ErrorMessage = "Custom Error Message #1"; args.IsValid = false; return; </code></pre> <p>What I get is "Custom Error Message #1" <strong>twice</strong> on the web form. Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload