Spence Green

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

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

Archive for the ‘ASP.NET’ Category

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)
if(!Postback)
{
   txtBox.Attributes.Add("onFocus","this.value='';");
}

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

Learning CSS for ASP.NET

without comments

Several weeks ago, I started implementing an ASP.NET 2.0 interface for a postal systems project. Although I had previous experience with n-tier web architectural design, the ASP.NET programming model was new to me, as were the constellation of languages and constructs used in modern web design. My first objective was to prototype all screens in the new interface. Initially, I thought of using Visio to layout the content, but I soon realized that it’s better to put a working “skeleton” in front of the user. The skeleton may lack tier 2 connections, but it should represent the interaction model, which includes:

  • Link structure between forms.
  • Dynamic, client-side content such as hover boxes and timers.
  • Proposed color scheme, which is an accessibility concern for colorblind users.
  • Site-wide style sheets.

Read the rest of this entry »

Written by Spence

November 27th, 2007 at 10:50 am

Posted in ASP.NET