Vincent Leung .NET Tech Clips

The latest tech clips from the .NET community

A better solution to find ASP.NET ClientIDs with jQuery

 

A small routine that returns us a jQuery object based on only the id:

function $$(id, context) {
    var el = $("#" + id, context);
    if (el.length < 1)
        el = $("[id$=_" + id + "]", context);
    return el;
}

So in simple usage to select my ctl00_MainContent_txtSymbol value both of the following work:

alert( $$("txtSymbol").attr("id") );

Or if I want to be specific about the container:

alert( $$("txtSymbol",$("#wrapper")).attr("id") );

Via A generic way to find ASP.NET ClientIDs with jQuery – Rick Strahl’s Web Log

October 15, 2009 Posted by Vincent Leung | ASP.NET, jQuery | | No Comments Yet

Paging and Sorting ListView Control with jQuery Tablesorter plugins within ASP.NET MVC

 

1.gif

This article provides a simple example of using jQuery along with the jQuery tablesorter and tablesorter.pager plug-ins to provide sorting and paging support for a listview within the context of an ASP.NET MVC application.

http://tablesorter.com/docs/

 

Paging and Sorting ListViews with ASP.NET MVC and jQuery

October 6, 2009 Posted by Vincent Leung | MVC, jQuery | | No Comments Yet

Form Validation using jQuery Validation plugin

image

In the example above, we only used three validation methods (required, email and url). There are several other methods that can be used here. Here are a few of them:

  • remote: requests a resource to check the element for validity.
  • min: makes the element require a given minimum.
  • date: makes the element require a date.
  • creditcard: makes the element require a credit card number.
  • equalTo: requires the element to be the same as another one.

You can find an exhaustive list of built-in validation methods at http://docs.jquery.com/Plugins/Validation#List_of_built-in_Validation_methods.

But I can’t find a suitable built-in method for my situation. Can I write my own method?” Yes you can! And its really easy.

Writing Your Own Validation Method

Calling the jQuery.validator.addMethod() method. It takes three parameters:

  • name: The name of the method, used to identify and referencing it, must be a valid javascript identifier.
  • method: the actual method implementation, returning true if an element is valid.
  • message: The default message to display for this method.

In the validate function, we specify that the ’sport’ field should be validated using the selectNone method.

image

Make sure to look at the source code behind these demos

Via Form Validation using jQuery

Another tutorial here

September 29, 2009 Posted by Vincent Leung | jQuery | | No Comments Yet

jQuery 1.3 Cheat Sheet

September 25, 2009 Posted by Vincent Leung | jQuery | | No Comments Yet

Using FireFinder & FireQuery Add-on for jQuery

September 22, 2009 Posted by Vincent Leung | jQuery | | No Comments Yet

Create Simplest Accordion Menu using jQuery

 

image

Step 1: Create HTML for your Menu

Step 2: Apply some style to your Menu using CSS – (optional using Round Corner CSS w/o images)

Step 3: Give life to your Menu using jQuery – using .click, .slideUp, .slideToggle

Via Accordion Menu: Create Simplest Accordion Menu using jQuery | ViralPatel.net

September 22, 2009 Posted by Vincent Leung | jQuery | | No Comments Yet

How to use Firebug to learn jQuery

 

A 9:59m video:

If the HQ version of the YouTube video still isn’t legible enough for you, Craig also made a full resolution WMV available as well.

Bookmarklet uses in the video

  1. Inject jQuery into any web page: jQuerify
  2. Point & Click CSS Selector:  SelectorGadget

Via Updated: See how I used Firebug to learn jQuery | Encosia

September 21, 2009 Posted by Vincent Leung | jQuery | | No Comments Yet

Microsoft Ajax CDN and the jQuery Validation Library

Scott Guthrie announced the launch of the Microsoft Ajax CDN on his blog last night. If you have not read his post, I recommend that you read it now to get a general overview of the CDN and how you can take advantage of the CDN to improve the performance of your ASP.NET Web Forms and ASP.NET MVC applications:

http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx

“The Microsoft Ajax CDN enables you to significantly improve the performance of ASP.NET Web Forms and ASP.NET MVC applications that use ASP.NET AJAX or jQuery.  The service is available for free, does not require any registration, and can be used for both commercial and non-commercial purposes.

ASP.NET 4.0 will make it especially easy for ASP.NET Web Forms developers to take advantage of the CDN. By setting one property of the ScriptManager control – EnableCdn=true, you will be able to redirect all requests for the built-in ASP.NET JavaScript files to the CDN and improve the performance of your Web Forms applications.”

In his announcement, Scott describes how both the ASP.NET Ajax and the jQuery libraries are included in the CDN. There is one more set of JavaScript files that are added to the CDN today that Scott did not announce: the jQuery Validation library.

If you are not familiar with the jQuery Validation library then you should know that this is one of the most popular form validation libraries used by jQuery developers. Microsoft is shipping the jQuery validation library with both ASP.NET Web Forms and ASP.NET MVC in Visual Studio 2010.  Furthermore, jQuery Validation library will be integrated with ASP.NET MVC.

Via Microsoft Ajax CDN and the jQuery Validation Library

September 17, 2009 Posted by Vincent Leung | AJAX, ASP.NET, MVC, jQuery | | No Comments Yet

75 Amazing CSS Navigations and jQuery Examples

August 14, 2009 Posted by Vincent Leung | Design, jQuery | | No Comments Yet

Ajax survey 2009: jQuery and MS Ajax are almost tied among .NET developers

June 25, 2009 Posted by Vincent Leung | AJAX, ASP.NET, jQuery | | 1 Comment