Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try using a ValidationGroup property across all your validators and the ValidationSummary.</p> <p><strong>EDIT:</strong> Another possibility could be the Server Validation Code</p> <pre><code>args.IsValid = (!CampaignRegistration.IsMemberRegistered(args.Value)); </code></pre> <p>if <code>CampaignRegistration.IsMemberRegistered(args.Value)</code> is returning false, "!" is making it true and therefore making it valid. I think you should get rid of the "!" as follows:</p> <pre><code>args.IsValid = CampaignRegistration.IsMemberRegistered(args.Value); </code></pre> <p><strong>UPDATE:</strong> In order for the ValidationSummary to display your custom validator message in a messagebox, you need to have <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx" rel="noreferrer">ClientValidationFunction</a> Code. If you need to display just the summary without a popup, this is not needed.</p> <pre><code>&lt;asp:CustomValidator ID="cvMemberNum" runat="server" CssClass="ValidationMessage" Display="Dynamic" ControlToValidate="txtMemberNum" ValidateEmptyText="false" OnServerValidate="cvMemberNum_Validate" ClientValidationFunction = "ClientValidate" ErrorMessage="This membership number is already registered"&gt;*&lt;/asp:CustomValidator&gt; //JavaScript Code. function ClientValidate(source, args) { args.IsValid = false; //you need to add validation logic here } </code></pre> <p><strong>MORE:</strong> If you don't want to do ClientSide Validation, try this trick to show the alert. Make this change to your CustomValidator ServerValidate method:</p> <pre><code>protected void cvMemberNum_Validate(object source, ServerValidateEventArgs args) { bool isValid = true; try { isValid = (!CampaignRegistration.IsMemberRegistered(args.Value)); } catch { isValid = false; } args.IsValid = isValid; if(!isValid) { if(!Page.IsClientScriptBlockRegistered("CustomValidation")) Page.RegisterClientScriptBlock("CustomValidation", "&lt;script&gt;alert('This membership number is already registered');&lt;/script&gt;"); } } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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