ASP.NET: Disable, Enable Validator Using Javascript
January 9, 2009
Doing this is pretty easy, if you know how or what method to use. I wanted to disable a Validator for a province TextBox if the country DropDownList chosen is USA because the state DropDownList will be enabled so the province should be inactive. Doing this server-side may be easy, but I wanted to use client-side Javascript so that no request will be sent whenever the OnChange event of the country’s DropDownList gets fired. Luckily, there is already a pre-made function in Javascript that disables Validators.
provinceValidator = document.getElementById(’ProvinceValidator’);
ValidatorEnable(provinceValidator, false);
Just set the second parameter as either true or false to enable and disable a Validator. I hope this will help those who have no clue how to go about it like I did until I found out about this function.
Regex For Creating Usernames
January 9, 2009
A regular expression (called regex) is a way for a programmer to instruct how a program should look for a specified pattern in text and then what it should do when each pattern match is found. Rather than going through each character of a string and doing matches, regex makes life easier for programmers to do search and matches. This sample regex is a good pattern for use in creating usernames.
The regex below means that only alphanumeric (only lowercase letters) are allowed including an underscore and a dot.
^[a-z0-9_.]$
ASP.NET: ValidationSummary For A CreateUserWizard Control
January 9, 2009
ASP.NET provides a control that uses the Membership API to create users on the fly via the CreateUserWizard control. The only drawback with this control is that you cannot include any other details like first name, last name, address and others. You would have to place all other details as a separate page, called a Wizard Step. When you use forms, naturally, you would have to use validation in order to have the correct data that will be stored in your database.
ASP.NET also has a nifty control called ValidationSummary that collects all errors of controls found in the tag and displays them as either a List or a Bulleted List. I typically got stuck for half a day looking for a solution because my ValidationSummary control does not display when it is in the CreateUserStep of my wizard. You can use a property called ValidationGroup to specify which set of controls will be collected by the ValidationSummary control for display. You do this by giving the ValidationGroup a name, which is case-sensitive by the way. My problem persisted because the ValidationSummary control for my CreateUserStep has a different name. I later found out that you would have to use the CreateUserWizard’s ID as the ValidationSummary’s ValidationGroup’s name for this to work. See the sample code below.
I specifically added a StartNavigationTemplate tag and overrode the asp:Button and its properties because the validation does not work if you do not set the button’s CausesValidation property to true. Hence, your ValidationSummary control would show nothing since no validation took place. Notice that my ValidationSummary’s ValidationGroup is called PersonalVG. You can name it any way you want but to use the ValidationSummary’s ValidationGroup for the CreateUserStep, you would have to use the CreateUserWizard’s ID for this to work. Otherwise, no validation error messages will be displayed and you will just be stuck on the CreateUserStep page.
ASP.NET: Get Access Of Control Within A CreateUserWizard
January 9, 2009
Getting access to a control from within c# is straightforward. You just call the ID name and call the method or property that you want to use. If you are going to get access to a control from within a CreateUserWizard control and your code may look something like
you call the Label control by
Label lbl = (Label) RegisterUserWizard.CreateUserStep.ContentTemplate.label;
Practical Javascript, DOM Scripting, and Ajax Projects
December 20, 2007
Practical Javascript, DOM Scripting, and Ajax Projects picks up where Beginning JavaScript with DOM Scripting and Ajax left off.
Frank Zammetti’s practical guide to real-world JavaScript and Ajax will have you developing actual client-side apps in no time. As more of a hacker than a theoretician, this kind of guide appeals to me. Usually when I start developing my own apps, some of the code used previously (in building sample apps) will be adapted and tweaked for my own purposes.
Some of the projects you’ll learn how to build in Practical Javascript:
* JSDigester - a library that simplifies (takes away the pain) of parsing XML on the client side
* Mashing up a list of hotels + a Yahoo Map for a user-entered zipcode
* Client-side persistence techniques
* A JavaScript validation framework
* Building widgets and working with UI widget frameworks
* Building a JavaScript mini-game (cool!)
* An Ajax-based client-server chat pplication
You can pick up a copy of Practical Javascript, DOM Scripting, and Ajax Projects at Amazon.com (avg. review score is 4.5 stars).
Beginning JavaScript with DOM Scripting and Ajax
December 15, 2007
Beginning JavaScript with DOM Scripting and Ajax will take you from knowing absolutely nothing about JavaScript to being able to manipulate the DOM, build basic Ajax applications and more.
Most of us who have been building websites since the pre-Ajax days learned JavaScript through a mish-mash of one-off scripts, validations, etc. If a book like this had been around, it surely would’ve offered a nice clean overview of the techniques available to the JavaScript programmer.
Luckily for the novice JavaScript programmer (or intermediate developer wishing to hone his craft), Beginning Javascript with DOM Scripting and Ajax does exist now and is the perfect way to learn the fundamentals from the ground up. The 2nd part of the book also focuses on Ajax and some of the interesting hacks one can use in that realm.
The author, Christian Heilmann, has a geeky sense of humor that keeps the reading light — for eaxmple Et Tu, Cache? (pg. 309):
Safari is the main offender as it caches the response status and does not trigger the changes (remember that the status returns the HTTP code 200, 304 or 404) any longer.
Adding this snippet tells the browser to test whether the data has changed since a certain date, i.e.:
request.setRequestHeader( ‘If-Modified-Since’, ‘Thu, 06 Apr 2006 00:00:00 GMT’);
request.send( null );
A bit out of context here, but just one example of the kind of thing you’ll find in Beginning JavaScript with DOM Scripting and Ajax.
Snap : New Search Engine
May 18, 2006
Snap is something which google might become in near future, as everything is getting AJAX’ed nowadays ;). As the title suggests, It’s indeed a marvelous way of searching. With some of the top programmers behind the project, there is no wonder it does so well. Most of the menu and search features are AJAX enabled and is interesting to use and has shortcut keys feature.
Snap’s another great feature is Snap widgets
- Snap Coupon Widget : Snap automatically coupons / special offers relavant to the search result.
- Snap Navigation/Company Widget : Snap’s first result on a company or navigation search will be a 360° view.
- Snap Map Widget : Typing the Zip code of a city returns a map.
- Snap Weather Widget : Typing the Zip code of a city with keyword “weather” gets you the weather report.
Ajax script resources
May 15, 2006
Working with Ajax? (Asynchronous Javascript and XML) Especially in web applications? Check out the web applications and scripts, coding secrets, and tips on the following web sites. As Ajax grows, so will these resources, so its highly recommended to bookmark them: (also great sites for HTML codes, CGI, Perl, Javascript, XML, and other coding scripts)
The Javascript Source: http://javascript.internet.com/ajax/
The Javascript Forum: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3
Ajaxed: http://www.ajaxed.com/
Open Cube: www.opencube.com
Javascript Kit: www.javascriptkit.com
and don’t forget my Yahoogroups web-design support group at www.yahoogroups.com/ “web-design”
Get Help With Ajax Freaks
May 10, 2006
While surfing the web I came across a great tutorial site for users of Ajax. Ajax Freaks is an informational website and you can use it while you are learning or if your still in the development stage.
They have over 200 articles, and they also have forums, downloads, scripts and tutorials. If you are completely unsure what Ajax is, try starting here and reading a few articles tutorials.
Yahoo! Instant Search is on !
April 8, 2006
Yahoo! Releases Instant Search, which is much like Google Suggest. Just that it shows up one result at a time with title and description which looks more like a search result rather than normal drop down suggetions.
Check out a whole range of other Yahoo! Beta’s at http://next.yahoo.com/






