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 6060691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:51:16+00:00 2026-05-23T08:51:16+00:00

I have two instances of a user control on a page. Both have fields

  • 0

I have two instances of a user control on a page. Both have fields and one submit button.

I have set validation groups on the fields and validators but for some reason when validating the two user controls’ validators fire.

  • 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-23T08:51:16+00:00Added an answer on May 23, 2026 at 8:51 am

    You could expose a property ValidationGroup in your UserControl that you would set from the Page. This value should be stored in ViewState, so that every instance of the UserControl will get different ValidationGroups(if your page assigns different).

    For example:

    Public Property ValidationGroup() As String
     Get
      Return CStr(ViewState("ValidationGroup"))
     End Get
     Set(ByVal value As String)
      SetValidationGroupOnChildren(Me, value)
      ViewState("ValidationGroup") = value
     End Set
    End Property
    
    Private Sub SetValidationGroupOnChildren(ByVal parent As Control, ByVal validationGroup As String)
        For Each ctrl As Control In parent.Controls
            If TypeOf ctrl Is BaseValidator Then
                CType(ctrl, BaseValidator).ValidationGroup = validationGroup
            ElseIf TypeOf ctrl Is IButtonControl Then
                CType(ctrl, IButtonControl).ValidationGroup = validationGroup
            ElseIf ctrl.HasControls() And ctrl.Visible = True Then
                SetValidationGroupOnChildren(ctrl, validationGroup)
            End If
        Next
    End Sub
    
    • http://www.craigwardman.com/blog/index.php/2009/05/setting-a-validation-group-on-a-user-control/
    • http://justgeeks.blogspot.com/2009/09/be-careful-using-hard-coded.html

    If you need different ValidationGroups in your UserControl the above recursive function won’t work, then you could assign it manually from codebehind. For example by putting the UserControl’s ID(might suffice) or ClientID in front of the ValidationGroup properties of the according controls. A good place where you could call this function would be PreRender.

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

Sidebar

Related Questions

I have an ASP.NET page with two instances of the same Web User Control
I have one user control. Two instances of user control one instance react on
I have two instances of an Address.ascx control in an ASP.NET MVC page. <h1>Shipping
I have two instances of a File Browser user control, the control is just
I have built two control containers on a page, one is using jquery-ui tabs
I have a user control that has a grid (the one you get automatically
I have two user controls (ascx); one contains some forms, and the other one
I have two instances of CFMutableBitVector , like so: CFBitVectorRef ref1, ref2; How can
I have two Java instances of java.util.Date and I have to find out if
Say I have two UUID instances: uuid1 = UUID.randomUUID(); uuid2 = UUID.randomUUID(); If those

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.