Click here to Skip to main content
13,199,852 members (71,312 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 13 Apr 2006

Syntax Change When Building Controls Dynamically in ASP.NET 2.0

, 19 Apr 2006
Rate this:
Please Sign up or sign in to vote.
From ASP.NET 1.x to ASP.NET 2.0 there has been a fundamental syntax change that applies to building server-side controls dynamically.


This tiny snippet will attempt to save developers that are porting ASP.NET 1.1 code to ASP.NET 2.0 code. Especially if controls are being built dynamically.

Using the code

The code posted here should replace any legacy ASP.NET code when converting to ASP.NET 2.0 if you are building server-side controls dynamically. It can even be a find and replace but not doing it will cause those controls to not pick up the correct values out of them.

Below is how I retrieved a value from an ASP.NET server control that was built on the fly or dynamically using VB.NET 2003.

Request.Form(me.ClientID & ":controlname")

The above code snippet will not work in Visual Studio 2005. There is no error thrown but the value property of the control returns nothing when there is a valid value available. This makes this little issue hard to catch without unit tests. Below I have included the same line of code as before but with one fundamental difference. The ":" gets replaced by "$".

Request.Form(me.ClientID & "$controlname")

This fixes the issue for ASP.NET 2.0. I did not see any documentation on this so I hope this is useful to someone.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
I am the lead software architect for Benefit Communications Inc. based in Nashville, TN. I specialize in enterprise development for windows and the web using .NET and IVR (Interactive Voice Response) systems. I hold the MCSD and MCDBA. I have a passion for video production. I love everything from shooting the video to editing it and everything in between. I love new technology and spend a lot of time on Microsoft's Research website. I am also very interested and amazed at the potential power of nanotechnology.

You may also be interested in...


Comments and Discussions

GeneralA better way to do this Pin
dapoussin20-Apr-06 5:43
memberdapoussin20-Apr-06 5:43 
QuestionDid you already try to use me.UniqueID instead? Pin
ptmcomp19-Apr-06 9:31
memberptmcomp19-Apr-06 9:31 
AnswerRe: Did you already try to use me.UniqueID instead? Pin
bholliman19-Apr-06 9:44
memberbholliman19-Apr-06 9:44 
GeneralRe: Did you already try to use me.UniqueID instead? Pin
ptmcomp19-Apr-06 9:58
memberptmcomp19-Apr-06 9:58 
GeneralRe: Did you already try to use me.UniqueID instead? Pin
bholliman19-Apr-06 10:38
memberbholliman19-Apr-06 10:38 
GeneralRe: Did you already try to use me.UniqueID instead? [modified] Pin
breischl13-Jul-06 5:53
memberbreischl13-Jul-06 5:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 19 Apr 2006
Article Copyright 2006 by bholliman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid