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

  • SEARCH
  • Home
  • 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 1049885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:41:11+00:00 2026-05-16T16:41:11+00:00

In my .aspx page, I’ve a ValidationSummary where I put error messages returned by

  • 0

In my .aspx page, I’ve a ValidationSummary where I put error messages returned by my Business Layer.

The error messages appears in the summary, ok, but not the “*” that normally appears next to the field =(

In the code behind, I’ve the following code:

CustomValidator cv = new CustomValidator();
cv.ControlToValidate = field.ID;
cv.ErrorMessage = "Error Message";
cv.Text = "*";
cv.IsValid = false;
Page.Validators.Add(cv);

Basically, I want to add the “*” next to each incorrect field, but without creating CustomValidators for each one… is it possible?

  • 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-16T16:41:12+00:00Added an answer on May 16, 2026 at 4:41 pm

    The ErrorMessage property will be displayed in the ValidationSummary while the Text property will be displayed where the Validator is. To meet your requirement, you need to put the CustomValidators beside those controls you want to validate.

    Since all the validators are generated in code behind, you need to add those validators to a proper position using Page.Controls.AddAt(int indexer, Control child) because CustomValidator is also a control.

    When you add the validator beside the textbox, you can get the exact index by following code.

    <form id="form1" runat="server">
        <asp:TextBox ID="tb" runat="server"></asp:TextBox>
        <asp:Button runat="server" Text="just a post back" />
    </form>
    
    protected void Page_Load(object sender, EventArgs e)
    {
         CustomValidator v = new CustomValidator();
         v.ErrorMessage = "error!";
         v.Text = "****";
         v.ControlToValidate = "tb";
         int index = form1.Controls.IndexOf(tb);
         form1.Controls.AddAt(index + 1, v);
    }
    

    NOTE: if you put the textbox in a PlaceHolder or some containers, you can’t get it by form1.Controls because Container.Controls returns the 1st level child controls only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a aspx page that has a UpdatePanel and a asp timer. the
I have a .aspx page that loads three separate .ascx controls to represent adding,
I am working on .aspx page that uses a t-sql query that uses a
I have created one aspx Page from that i need to access the property
I had an aspx page which was working well, but suddenly I am getting
I have simple aspx page that has a form and a input field in
I have an aspx page that contains a user control. The user control has
I have an aspx page there i have a button that fix on it's
I have an aspx Page that contain a userControl that contains textboxes. in the
I have an a aspx page, but all content is generated by hands(yes I

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.