Ian Blackburn

March 2004 Entries

Secure your connection string in web.config

Thought I'd just put a quick post together on this one, since I am often asked about it.

If you are worried about leaving names and passwords in web.config, but like the ease of it, then a very simple way of encrypting the values, putting them in the registry and then retrieving them through a simple change in syntax in web.config is detailed here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q329290; it also includes a little command line utility to do the work for you.  Nice.

 

Microsoft go Welsh, but still spell Colour without a u!

Microsoft must be reading my blog ;-). In British English or English? I wondered why the Welsh language isn't supported in .net.  Well it seems that that is changing for Windows at least.  The BBC: Microsoft works on native tongues, states "The Welsh language is to be introduced into Microsoft Windows", so presumably .net culture support will come with that too.

No mention on whether the English-GB culture will be supported properly though, so that Color is spelt Colour in the Windows UI.  Maybe I should start a campaign?

asp.net without JavaScript

The UK government are issuing guidelines for all government web sites which includes the requirement that there must be an alternative to javascript in web pages.  So how does this affect asp.net?  You could modify the controls you use to add <NOSCRIPT> elements to the output, but this would be quite a large task.  A better approach would be to only use the server controls that do not need javascript for the postback.

At first I thought this would be a major headache, but it turns out that only the following standard controls use javascript (taken from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconclientscriptinwebforms.asp):

  • The LinkButton and HtmlButton server controls require script. (This is not true for the Button Web server control or the HtmlInputButton or HtmlInputImage controls.)
  • By default, the Calendar control implements month navigation and day selection using LinkButton controls. If you set control properties to allow users to select a day, week, or month, or if you allow users to navigate to other months, then the Calendar control will generate client script. If you use the Calendar control simply to display a single month with no selection or navigation, the control does not require client script.
  • Any Web server control whose AutoPostBack property is set to true; the client script is required so that the control will post the page.
  • The Web validation controls, which require client script to support client-side validation. If the client does not support script, validation will run on the server only.

So in fact if you don't use these controls - and it is perfectly possible to live without them (though of course the user experience could suffer slightly) it's not a problem at all!

 

 

Lightscribe - Burn an Image as well as your data onto your cd/dvd

This is a pretty neat technology from HP - no more messing about with sticky labels or cd-r pens, instead the  technology uses a chemical on one side of specially-coated discs. Once you have burnt the data, just flip it over and the image/label can be etched onto the disc using the same drive (though you will need a new Lightscribe compatible drive, available Summer 2004).

See the details here: http://www.lightscribe.com/

 

Default button in asp.net

One of the things that often crops up when designing asp.net web pages, and testing them in ie, is that there does not seem to be an easy way to set the default button.  This is the button that would be "clicked" when the user just presses enter on the form, and it's a feature of ie.

Previously I have solved this through client-side javascript, but I recently came across a much neater solution in Mike Webs blog.  He has a good explanation of how it works so I won't go into it here, save to say that all you need to do is add the following to your page_load event:

Page.RegisterHiddenField("__EVENTTARGET", "MyDefaultButton");

This seems to work a treat, and Mikes's explanation certainly makes sense.  This is a whole lot easier than using Javascript or custom controls too..