Skip to content

Codepolice

  • ⤫

Using JQuery Validation plugin with ASP.NET

Posted by Judy Alvarez Posted on February 25, 2022March 1, 2022
0

Like everyone else, I’ve been playing around with JQuery a lot lately. Asp.net and JQuery are not the best friends in the world but I guess it will be a lot better when using ASP.NET MVC. Microsoft also announced that they will support JQuery natively in future versions. Nice!

If you want to learn more about ASP.NET and Jquery be sure to read both Rick Sthral’s and the Encosia blogs.

I’m working on a new project now where I am trying to stay away from asp.net ajax mainly because of performance reasons but also just because I want to learn something new. Today I’ve been using the JQuery Validation plugin.

There is a lot of documentation on how to use it on the documentation pages for the plugin but I want to share with you one thing that I had problems with.

This is some regular example code that all the samples use. The problem here is that for example “EmailTextbox” is not the ID of the control but the name.

$(document).ready(function() {
// validate signup form on keyup and submit
$("#aspnetForm").validate({
   rules: {
       OpenIdTextbox: "required",
       NicknameTextbox: {
          required: true,
          remote: "resources/nickname.aspx"
          },
       EmailTextbox: {
          required: true,
          email: true
          }
       }
    });
});

I scratched my head for a long long time when I used ctl00_ContentPlaceHolder1_EmailTextbox and nothing worked at all. So what you have to do is change this to something like this.

$(document).ready(function() {
 // validate signup form on keyup and submit
 $("#aspnetForm").validate({
     rules: {
         ctl00$ContentPlaceHolder1$OpenIdTextbox: "required",
         ctl00$ContentPlaceHolder1$NicknameTextbox: {
             required: true,
             remote: "resources/nickname.aspx"
         },
         ctl00$ContentPlaceHolder1$EmailTextbox: {
             required: true,
             email: true
         }
     }
 });
});

You could of course also use some method that rewrites the Control.UniqueID to a name and use <%= %> to get the name of the control.

Categories: JavascriptTagged: asp .net interview questions, asp net authentication, asp net controls, asp net core 1.0, asp net core logging, asp net core middleware, asp net core mvc tutorial, asp net developer, asp net features, asp net interview question, asp net interview questions for 10 years experience, asp net interview questions for 5 years experience, asp net là gì, asp net latest version, asp net machine account, asp net meaning, asp net mvc interview question, asp net mvc tutorial step by step for beginners with examples, asp net project, asp net projects, asp net session, asp net version, asp net web api tutorial, asp net web services, asp net webservice, difference between asp net and asp net core, learn asp net, session asp net, webservices in asp net, what is asp net core

Post navigation

Previous Previous post: Create a tag cloud with a limited amount of tags in ASP.NET and LINQ
Next Next post: Join and Group By with LINQ to Entities

Related Posts

  • Bringing Python apps into Node

    #​596 — October 14, 2025 Read on the Web 📂 A Modern Guide to Reading and Writing Files in Node — A comprehensive guide to various methods for working with files, from promise-based methods through to working with streams, processing files concurrently, using file handles, and memory-efficient techniques. Luciano Mammino A Way to Integrate Python ASGI with Node.js

    Posted by Posted on October 14, 2025
    0
  • Vite gets its own documentary

    #​756 — October 10, 2025 Read on the Web JavaScript Weekly ▶  Vite: The Documentary — From the same creators of the fantastic ▶️ Node.js, ▶️ Angular and ▶️ React documentaries comes an up to date look at Vite, the build tool that has taken the JavaScript ecosystem by storm in recent years. Many luminaries make an appearance to

    Posted by Posted on October 10, 2025
    0
  • npm security best practices to consider

    #​595 — October 7, 2025 Read on the Web 15 Recent Node Features That Can Replace Popular npm Packages — Many features that once required third-party packages are now built into the runtime itself. Here’s a look at some of the most notable that you may want to experiment with, prior to reducing unnecessary dependencies. Lizz

    Posted by Posted on October 7, 2025
    0
  • React 19.2 is in the building

    #​755 — October 3, 2025 Read on the Web JavaScript Weekly The State of JavaScript 2025 Survey — Each year, Devographics runs an epic survey of as many JavaScript community members as it can and turns the results into an interesting report on the state of the ecosystem – here’s the results from 2024. If

    Posted by Posted on October 3, 2025
    0
  • Using Node with Cloudflare Workers

    #​594 — September 30, 2025 Read on the Web 🗓️ We’re back after taking a week off for my birthday. I’ve never bothered to do that before, but I figured I’d give it a go, and.. it was good 😅 We’re now back every week until Christmas!__Peter Cooper, your editor A Year of Improving Node.js

    Posted by Posted on September 30, 2025
    0
  • The first browser with JavaScript landed 30 years ago

    #​754 — September 26, 2025 Read on the Web JavaScript Weekly Give Your AI Eyes: Introducing Chrome DevTools MCP — The Chrome team has released an MCP server for Chrome DevTools, enabling agents like Claude Code or OpenAI Codex to use the DevTools to debug and analyze the performance and behavior of your webapps (or

    Posted by Posted on September 26, 2025
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Bringing Python apps into Node
  • Vite gets its own documentary
  • npm security best practices to consider
  • React 19.2 is in the building
  • Using Node with Cloudflare Workers
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice