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

The Archive Base Latest Questions

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

I have some fields to be validated on the server (CustomValidator) which is in

  • 0

I have some fields to be validated on the server (CustomValidator) which is in a separate user control and my Submit button is in the page not in the user control.

What I have done is, I placed all my Validation Methods in the code behind of my usercontrol (ascx.cs) and the page validation is in the code behind of the page (aspx.cs). I put them in the same ValidationGroupName (fields and Submit button). usercontrol (ascx) is a child of my page (aspx). I have already placed CauseValidation="true" to my Button and UseSubmitBehavior="true". The problem is it does not validate. What could be the problem in this?

Note: I cannot put the the Button to be part of the usercontrol.

Edit:

in my aspx page, click event of the button has this.Page.Validate(ValidationGroupName) and all of my validators are on the fields on a separate control (ascx) which is a child of the aspx page.

protected void Button1_Command(object sender, CommandEventArgs e)
{
    if(e.CommandName.Equals("Validate", StringComparison.Ordinal))
    {
        this.Page.Validate("MyValidationGroup");
        if(this.Page.IsValid)
        {
            // I'll change my View here.
        }
    }
}

My Button looks like

<asp:Button ID="Button1" runat="server" UseSubmitBehavior="true" CommandName="Validate" 
                    Text="Submit" OnCommand="Button1_Command" CausesValidation="true" ValidationGroup="MyValidationGroup" />

The above snippet is located in my aspx page.

I’ve tried to put the same button on the ascx page, it works fine. My thought is since the ascx page is under the aspx page. When the button event on aspx page is fired (Button1), the rest of the event in ascx page is not fired. I’ve tried to put breakpoints on the button event and validator events, if the button of the page (aspx) is the one I click, it will not stop on my validator events, if the button on the control (ascx) I click it will stop to the validator events. What could be the remedy for this?

  • 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-16T20:23:17+00:00Added an answer on May 16, 2026 at 8:23 pm

    Have you tried calling ucName.Page.Validate(); in the button click event?

    (where ucName is whatever you called the user control in the markup)

    Edit: OK this simple code below works fine for me, the only way I broke the validation was setting my user control to visible = false; Can you post more of your code?

    Parent page markup:

    <uc:ucTest id="ucName" runat="server">
    <asp:Button ID="btnTest" runat="server" Text="Test validation" onclick="btnTest_Click" />
    

    code behind:

    protected void btnTest_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Response.Write("Hi!");
        }
    }
    

    user control markup:

    <asp:TextBox ID="txtDummy" runat="server"></asp:TextBox>
    <asp:CustomValidator ID="CustomValidator1" runat="server" 
         ErrorMessage="*"
         ControlToValidate="txtDummy" 
         onservervalidate="CustomValidator1_ServerValidate">
    </asp:CustomValidator>
    

    code behind:

    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (txtDummy.Text.Length > 0)
        {
            args.IsValid = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in which some of the fields need to be validated
I have a submit button on a page. <asp:Button ID=btnSubmit runat=server Text=Save Test OnClick=btnSubmit_Click
I have a fieldset in which I have some input fields and a checkbox.
I have a JPanel which contains some fields. The height of the JPanel is
I have a table in database that is having some fields one of which
I have to prepare a report which is getting some fields data from conf
I have a form on my PHP page which performs some ajax validation (that's
i have some fields in my database table,and a field with phone name ,
I use VB to get data through my form. I have some optional fields
I have some markup for a set of fields within a form: <ul> <li>

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.