List of ASP LCID language codes for Metabase.xml

16 04 2009

After spending ages scouring the net for a list of ASP LCID codes, I’m came across this list which is actually for Word and associated development tools like VB for Applications. This list of codes should also be valid for the AspLCID entry in C:\windows\system32\inetsrv\metabase.xml.

The default seems to be set to 2048 but the following list on MSDN lists all of the language codes available.

Of course, the language can be set in a number of different ways, either using the ASPLCID code in the MetaBase.xml, by changing the culture information on the pages or through the web.config.

See the following article:

The main codes used for most english speaking developers will be
English Australia 3081 (&HC09)
English Canadian 4105 (&H1009)
English U.K. 2057 (&H809)
English U.S. 1033 (&H409)

There is also this MSDN link here:

Understanding ASP.NET web.config

28 11 2007

Have you problems with understanding the ASP.NET web.config file?

Its difficult remembering the structure of the web.config file and also what each configuration section/items are available and what they mean.  I often refer to previous versions of my web.config in order to understand which bits I need to add to get the desired functionality in my web app.

Here MSDN details all of the sections and the web.config file: MSDN web.config Info

XML Country List

1 10 2007

The chances are that, at some point during your development project, you’ll need to capture data from you users. Also very likely (and very useful f0r that matter) is to capture where they are from.

The first thing you need is a listbox of countries from where they can select from. To save you time and energy, there is no need to type out every single country into the listbox. This would be a real test of your geographical knowledge!

Follow these simple steps:

1. Drop a listbox control onto your ASP page.
2. Drop an XML datasource control onto your ASP page.
3. Download and copy the countries.xml file into your project (preferably into your app_data folder).
4. Click on the XML datasource smart tag (the small arrow) and wire-up the datasource to your XML File
Note: You have to do a refresh on your project files by right clicking on your folder or root folder in the solution explorer followed by refresh before the XML file will been seen by the XML datasource.

5. Bind the listbox to your XML datasource and voila!

The only problem with this method is that because the country code is stored as inner text within each XML node, the only values than can be shown in your listbox is the ISO code and the 2 letter country code.  Not much use to you really!  You could either change the format of this XML file or access the inner text of each node.

To do this check out Mads Kristensen’s blog. He’s provided a method to programmatically populate the listbox in ASP code behind. Check out his blog here

FindControl on a CreateUserWizard template

26 09 2007

I wanted to be able to customise the CreateUserWizard control by adding some components onto the CreatedUser template such as a few labels, and then display the username and password in these labels.

The first thing is to ensure the code for this goes in the following event stub:


You then need to access your labels on the template. Heres how:

Dim lbl As Label
lbl = CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("lblUsername")
lbl.Text = etc....

As easy as that!

GetPassword exception in ASP.NET membership

26 09 2007

I tried a new method call today on ASP.NET MembershipUser.

Dim thisUser As MembershipUser = Membership.GetUser(thisUserName)

Then I called the following:

lbl.Text = thisUser.GetPassword

and got the following exception:

This Membership Provider has not been configured to support password retrieval.

After some investigation I noticed I needed the following in my web.config (Notice those in RED are the attributes that are required and were added in order to support the GetPassword method):

<add name="AspNetSqlMembershipProvider"
requiresUniqueEmail="false" />

Following these additions, you need to add the following to web.config. There is a automatic key generator at the following: machineKey Generator

<machineKey validationKey="11D7D8362528F04266ACACDDEA7..."

You should then be able to support the GetPassword method().

If you don’t add the machineKey then you’ll get a different error as follows:

You must specify a non-autogenerated machine key to store passwords in the encrypted format. Either specify a different passwordFormat, or change the machineKey configuration to use a non-autogenerated decryption key.

Nice error hey? This is part & parcel of understanding a lot of the ASP.NET membership framework, you fix something somewhere, and you end up with a different error somewhere else. Its a big learning curve but a worthwhile one at that!

Renaming/Changing username in ASP.NET

24 09 2007

I came across a situation today where I wanted to change usernames of a set of users within my web app. I created a list of around 20-30 administrative users all with usernames based on the location of their office. However, I’ve now been advised that these usernames would be better stored as 2 letters. This would certainly make login easier for the administrative users, but I now have the task of either deleting them all and starting again or finding some other way of renaming the usernames.

After a quick google, I’ve noticed there is no quick way of doing this apart from this method described here:

Change username in ASP.NET

Maybe this will be something that will be added in future versions of ASP.NET?!

Today, I had to go through all the usernames and change them, and all I ended up doing was using the Database editor (in t his case myLittleAdmin) provided by my web hosting company.

It was as simple as clicking on the aspnet_Users table and then modifying each row, in particular the UserName and  LoweredUserName fieldsYou could even create some SQL to go and update each row based on some other piece of data perhaps?