Spence Green

التكرار يعلم الحمار

I work at Lilt. In addition to computers and languages, my interests include travel, running, and scuba diving. more...

Two Useful, Totally Unrelated ASP.NET Topics

without comments

Here are two coding tips that I have found useful in recent days:

Explanatory text in a textbox can force the user to read directions. The textbox could say something like, “Enter search terms here separated by commas.” But when the user places the cursor inside the textbox, the instructions should clear. The standard ASP.NET textbox control does not have an OnFocus event, but the same effect may be achieved with JavaScript. Add an attribute to the textbox control during the Page_Load event:

//Note that value is set to an empty string (two single quotes)

Some ASP.NET controls use JScript Eval statements for databinding. In some cases, you may want to include single and double quotes in the Eval format string. Use HTML escape sequences in place of quotes:

Single quote: '
Double quote: "

Consider the following example, which uses an Eval format string:

   < %# Eval("Url","this.window.href=&apos;{0}&apos;") %>

Written by Spence

November 29th, 2007 at 3:18 pm

Posted in ASP.NET

Leave a Reply

You must be logged in to post a comment.