LANGUAGES: All .NET Languages
ASP.NET VERSIONS: 1.0 | 1.1
Get out of trouble - and stay out of trouble - with this batch of ASP.NET tips and tricks.
By Don Kiely
If you participate in any of the online ASP.NET forums - and there are many excellent ones - you probably know there are a lot of questions that are asked over and over. I constantly compile answers to these kinds of questions, so here is my Tip-a-Thon, Version 1.0.
Application Blocks. If you're not already using them, check out Microsoft's various application blocks. The Data Access and Exception Management blocks have been out for a while, and they have released several more in the last couple of months. You can find them all off of Microsoft's Patterns and Practices site (http://www.microsoft.com/resources/practices/), which has a wealth of resources for designing .NET apps.
Default Buttons. Have you ever needed a default button on a Web form? Andy Smith came up with a cool solution for default buttons - a non-visual solution you can get with source code at http://www.metabuilders.com/Tools/DefaultButtons.aspx.
Regular Expressions. Do you use regular expressions a lot? You should, and for a lot more than just validation. But if don't know them well, it can be frustrating to write them and get them just right. You can use the Expresso tool (http://www.codeproject.com/dotnet/Expresso.asp) for building Regular Expressions. You can also find a nice library of rated regular expressions at http://www.regexlib.com/. Be sure to return the favor and contribute some of your own!
Books Without Which I Can't Develop. These are the books that I've gotta have near me:
- XML for ASP.NET Developers, by Dan Wahlin (http://www.amazon.com/exec/obidos/ASIN/0672320398)
- ADO.NET and ADO Examples and Best Practices for VB Programmers (http://www.amazon.com/exec/obidos/ASIN/1893115682) and ADO.NET Examples and Best Practices for C# Programmers (http://www.amazon.com/exec/obidos/ASIN/1590590120), both by Bill Vaughn
- The Guru's Guide to Transact-SQL (http://www.amazon.com/exec/obidos/ASIN/0201615762), by Ken Henderson
- Advanced Transact-SQL for SQL Server 2000 (http://www.amazon.com/exec/obidos/ASIN/1893115828), by Itzik Ben-Gan and Tom Moreau
- Microsoft ADO.NET (Core Reference) (http://www.amazon.com/exec/obidos/ASIN/0735614237), by David Sceppa
Run a program from .NET code. Use System.Diagnostics.Process.
When ASP.NET Is Sick. Run aspnet_regiis.exe in C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705 (or whatever your Windows system directory is called, and whichever version of the framework you're using) with the "-i" switch to reregister everything with IIS without reinstalling .NET. There are some other useful switches with the tool, so be sure to check them out.
Recreate Dynamic Controls Automatically. When your dynamic controls disappear mysteriously, check out the solution Denis Bauer (he's with Microsoft Germany) came up with at http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=121144.
SQL Server Does Not Exist or Access Denied, and Other Sad Server Stories. I covered this fairly thoroughly a few months ago (http://www.aspnetpro.com/newsletterarticle/2003/01/asp200301dk_l/asp200301dk_l.asp), but there's a pretty good chance you're running your ASP.NET app under the anonymous ASPNET user. That login has to have permission to access the SQL Server or MSDE database, which it doesn't seem to have. Also, check out the information and patch (http://www.asp.net/faq/ms03-32-issue.aspx) if you get the dreaded 'Server Application Unavailable' error after applying a security update for IE on Windows XP.
I'll have more tips for you next time. If you have any tips or some refinements of these, please let me know. Or, better yet, come visit the Microsoft-sponsored ASP.NET community at http://www.asp.net and share them there!
Don Kiely is senior technology consultant for Information Insights, a business and technology consultancy in Fairbanks, Alaska. E-mail him at mailto:[email protected].