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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:27:40+00:00 2026-06-08T00:27:40+00:00

I’m writing a user control that uses jquery.validate instead of the validation controls to

  • 0

I’m writing a user control that uses jquery.validate instead of the validation controls to work with required/email fields. I build a quick test page and everything worked fine. However if I extracted some of the functionality into a web control and dropped that onto the page, then the if(Page.IsValid) { } check in the code-behind always seems to be true and none of the validation seems to work anymore. Here is the code I’m using for the web control:

Front-end:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" I          nherits="JqueryValidateTest.TestControl" %>
<div id="control-wrapper">
    <asp:TextBox ID="txtName" runat="server" ClientIDMode="Static"></asp:TextBox>
    <asp:TextBox ID="txtEmail" runat="server" ClientIDMode="Static"></asp:TextBox>
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
        onclick="btnSubmit_Click" />
</div>

Code-behind:

protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnSubmit_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
        Response.Write("Page is valid");
    else
        Response.Write("Page is not valid");
}

This is the html/js for the page the control is dropped onto:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JqueryValidateTest.Default" %>

<%@ Register Src="TestControl.ascx" TagName="TestControl" TagPrefix="uc1" %>
<!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>
    <style type="text/css">
        input.valid
        {
            border: 2px solid lime;
        }
        input.error
        {
            border: 2px solid red;
        }
    </style>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js">     </script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
        jQuery.validator.messages.required = "";
        jQuery.validator.messages.email = "";
        $('#form1').validate({
            rules:
            {
                txtName: {
                    required: true
                },
                txtEmail: {
                    required: true,
                    email: true
                }
            },
            messages: {}
        });
    });
    </script>
</head>
<body>
<form id="form1" runat="server">
<div>
    <uc1:TestControl ID="TestControl1" runat="server" />   
</div>
</form>
</body>
</html>

I thought it may be something to do with the ids of the controls changing but I’ve changed the ClientIDMode to static and they seem to be staying the same.

Does anyone know why this is failing?

Thanks

  • 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-06-08T00:27:42+00:00Added an answer on June 8, 2026 at 12:27 am

    Use this :

    <%= txtName.UniqueID %> {
                    required: true
                },
     <%= txtEmail.UniqueID %> : {
                    required: true,
                    email: true
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need to clean up various Word 'smart' characters in user input, including but

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.