About

I'm Mike Pope. I live in the Seattle area. I've been a technical writer and editor for over 30 years. I'm interested in software, language, music, movies, books, motorcycles, travel, and ... well, lots of stuff.

Read more ...

Blog Search


(Supports AND)

Google Ads

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

Quote

Writers like to think that writing is like Arctic exploration or flying the Atlantic solo but really it's more like golf. You've got to go out and do it every day and live by the results. You can brood over it but in the end you've got to take the club out of the bag and take your swing. You hit the ball to where it wants to go, a series of eighteen small steel cups recessed in turf, on a course that others have traversed before you. You are not the first. You accomplish this by practicing an elegant economy you learned from others and thereby overcoming your damn self-consciousness which trips you up every time.

— Garrison Keillor



Navigation





<November 2021>
SMTWTFS
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

Categories

  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  

Contact Me

Email me

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 9/13/2021

Totals
Posts - 2638
Comments - 2646
Hits - 2,426,630

Averages
Entries/day - 0.39
Comments/entry - 1.00
Hits/day - 361

Updated every 30 minutes. Last: 9:14 PM Pacific


  10:51 PM

One of the many cool things in ASP.NET 2.0 is that you can declaratively set a default button. This makes the pain of the various hacks (#) pretty much go away, bye-bye.

With this in mind, I set the default button for my main blog page (yer on it right now) to be the Search button, using this syntax:
<form runat="server" DefaultButton="buttonSearch">
I quick-like tested it and it worked just fine.

But I soon got a complaint that when the page first opened, it was scrolling down a bit. I had a look, and sure enough. Now that I had a default button for the form, when the page loaded, it set the focus on the button, which was below the fold. That's not what I wanted.

The DefaultButton attribute can be applied to containers, so to fix this, I removed the attribute from the <form> tag. The box you see as Search is a <td> element in a table. So within the <td> element I added an <asp:panel> element and set its DefaultButton attribute to point to the Search button.

The morals of the story are that a) setting a default button will by default (haha) also set focus, and that therefore and/or maybe b) you want to either move your default button to an appropriate location or scope it to a suitable container. (Does this make sense? Hope so.) Anyway, I humbly submit this as your tip of the day. :-)

[categories]   ,

|