I recently had a task in one of my current projects that required me to extract the authentication mode of the current solution’s web.config file. The only was I figured out how to do it was by parsing the XML of the file by hand as shown below (Yeah, I know, it’s VB.NET. I do what the client wants.):

 

            Dim config As New System.Xml.XmlDocument()
            config.Load(Server.MapPath("\Web.config"))
            Dim authMode As System.Xml.XmlNode = config.SelectSingleNode("/configuration/system.web/authentication/@mode")
            Return authMode.Value

While that works just fine, it seems a little primitive and I figured Microsoft would have introduced a library to get that kind of data. Anyone know of any?

 

I’ve decided to start posting the solutions I find in irritating little problems that take me forever to find.  Some of these will probably be obvious, but hopefully it might save someone’s time.  My current problem was that I had a DotNetNuke module that was sitting in a AJAX Update Panel.  I needed to set the focus to a particular control based upon a post back click on a radio button.  The standard focus() method didn’t work and neither did the old fashioned RegisterClientScriptBlock stuff with a provided JavaScript function.  Turns out there is an extremely easy way to do this which is to use the ScriptManager SetFocus method using the base Page for the control as shown below:

ScriptManager.GetCurrent(Me.Page).SetFocus(txtApplicationDate)

Hope that helps someone.

Mar 182008
 

Apparently, I only rate as a Slightly Dorky Nerd King via the Nerd 2.0 test.  Slightly disappointing . . .

 

NerdTests.com says I'm a Slightly Dorky Nerd King.  What are you?  Click here!

 

Joel Sposky, in his usual highly amusing style, takes on the new IE 8 controversy and points out the enormous gulf between the standards world and the world the rest of us really work in.  I often compare this difference to the difference between open-source and commercial software developers.  There are those who say that it must be done the standard way and there are others that say it should be done to make it easy for the user.  And the rest of us poor suckers live somewhere in between.  My favorite quote from the article:

The web standards camp seems kind of Trotskyist. You’d think they’re the left wing, but if you happened to make a website that claims to conform to web standards but doesn’t, the idealists turn into Joe Arpaio, America’s Toughest Sheriff. “YOU MADE A MISTAKE AND YOUR WEBSITE SHOULD BREAK. I don’t care if 80% of your websites stop working. I’ll put you all in jail, where you will wear pink pajamas and eat 15 cent sandwiches and work on a chain gang. And I don’t care if the whole county is in jail. The law is the law.”

Martian Headsets – Joel on Software

Page optimized by WP Minify WordPress Plugin