May 24, 2005

Using CodeDOM Code Generation to Implement Repetitive Patterns

attern gurus are quick to remind us that patterns are not code. Patterns exist at a level above the code. Or, as Martin Fowler says (PDF), “Patterns provide a mechanism for rendering design advice in a reference format.” This implies that patterns are too abstract to be implemented in a

Dynamically Remove HREF from the Anchor Tag

Sometimes you need to remove a link from an anchor tag dynamically. You can do this with JavaScript.Take a look at this example: Devx To remove the link (i.e, the href) from the tag, use the following code: document.anchors[“ancDevx”].removeAttribute(“href”);

Using a MySQL Database to Validate Usernames and Passwords

A common mistake many developers make is using their MySQL database to validate a user name and password combination. Here’s a typical SQL query checking for the existence of a user trying to login: SELECT 1 FROM WHERE USERNAME=”” AND USERPASSWORD=”” If a record matches, the database returns that record

Enabling Data Source Control Caching Increases Performance

To achieve faster performance, enable the caching property in your database-driven data source control (this is applicable only for ASP.NET 2.0). CacheDuration indicates the number of seconds the data is be kept in the memory. When that time is up, the sqldatasource control fetches the data from the database. You

Read the Entire Text Element

SAXParser’s DefaultHandler provides a callback for public void characters(public char[] ch, int start, int length, etc.) and throws a SAXException for reading element text contents. You can read the char array in any invocation of the DefaultHandler and convert it into a String object for your use. However, this single

Testing with an Application Verifier

Application Verifier is a tool for testing user-mode applications for compatibility with MS Windows XP. It comes in handy when you’re troubleshooting issues like common programming mistakes related to memory allocation, lock usage, and handle usage. The tool exposes instrumentation that already exists in the Windows OS. The Application Verifier’s