Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7502651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:56:52+00:00 2026-05-29T20:56:52+00:00

I am setting a RegularExpressionValidator at runtime in my aspx control as per below

  • 0

I am setting a RegularExpressionValidator at runtime in my aspx control as per below

 <asp:RegularExpressionValidator ID="revValue" runat="server" ControlToValidate="txtZipCode"
                    ValidationExpression='<%=this.SettingManager.GetSettingValue("ZipCodeValidationExpression")%>'
                    ErrorMessage="Invalid Zip Code." Display="Dynamic" />

On the page, if I enter an invalid zipcode I do get the message “Invalid Zip Code”, however, if I then enter a valid zip code nothing happens and the message remains “Invalid Zip Code”.

If I manually set the expression as per below

 <asp:RegularExpressionValidator ID="revValue" runat="server" ControlToValidate="txtZipCode"
                    ValidationExpression="^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$"
                    ErrorMessage="Invalid Zip Code." Display="Dynamic" />

It works fine. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:56:53+00:00Added an answer on May 29, 2026 at 8:56 pm

    Sample code in “Code Behind”

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    
    public partial class Default3 : System.Web.UI.Page
    {
        public static string GetErrorMessage()
        {
            return "Your Error Message";
        }
    
        public static string GetValidationExpression()
        {
            return @"\d+";
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                qw.ErrorMessage = GetErrorMessage();
                qw.ValidationExpression = GetValidationExpression();
            }
        }
    }
    

    Sample code in ASPX Page

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:TextBox ID="txt1" runat="server">
        </asp:TextBox>
        <asp:RegularExpressionValidator ID="qw" runat="server" ControlToValidate="txt1" Display="Dynamic"></asp:RegularExpressionValidator>
        <asp:Button ID="ed" runat="server" Text="ed" />
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Setting value in html control in code behind without making server control <input type=text
Setting up an integration server, I’m in doubt about the best approach regarding using
Setting up ASP.net MVC with Linq2SQL or Entity Framework's context to have scaffolding work
Setting the scene: My asp.net web application carries a version number which is incremented
After setting up TemplaVoila like ever i end up in this view. I set
Setting up CI within Microsoft Team Foundation Server, I have a build that will
Setting up SVN using Apple Developer Connection manual ( http://developer.apple.com/mac/articles/server/subversionwithxcode3.html ). Regardless of it,
Setting up maintenance plan for sql server 2008 backup Don't understand what exactly backup
Setting up curl like this: $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$this->domain); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3); curl_setopt($ch,CURLOPT_FAILONERROR,TRUE); curl_setopt($ch,CURLOPT_USERAGENT,Useragent); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
Setting role when creating new user with ASP.net MVC I am looking at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.