Tuesday, March 20, 2007

ASP.Net 2 Control Client Names with Dollars not Colons

Currently migrating a lot of .Net 1.1 code to .Net 2, and was having problems with one particular ASP.Net page. This page uses a custom control that we have written to display one of our objects. It is a composite control that displays a number of text boxes, check boxes and the like, to represent the object passed in to it.

Well this control pulls form variables during the post back, and updates the underlying object with what the user has entered. The problem was that on a Windows XP development PC this all worked fine, but during a test deploy onto a Windows 2003 server the page didn't save the updated values.

The names of the controls had all been separated with a colon (:) on the development PC, and a dollar ($) on the server. This was a problem as the custom control was set up to separate the names using the colon, which had always worked in the past.

The answer came from a forum posting.

On the development PC the Web.config file had the setting

<xhtmlConformance mode="Legacy"/>

in the system.web section, but the server did not.

No comments: