I’m having a problem with the ID property of dynamically loaded UserControls changing during the Page lifecycle. More specifically the ID property changes when the system calls Page.Form.RenderControl(htmlTextWriter); Before it is called the control has ID ‘ctl84’, but after the call it has ID ‘ctl99’.
The output from htmlTextWriter contains the original ID, however inspecting the Control’s ID property in the VS 2008 debugger reveals that it has changed.
The application is running inside an MCMS 2002 (Microsoft CMS 2002) framework using .NET 2.0, converted from 1.1 and xhtmlConformance=’Legacy’ is not enabled.
I need the ID to be constant throughout the Page lifecycle.
Edit: Setting the ID property manually is not an option.
Are you explicitly assigning an ID to the control from code?
If you are the ID should stay the same.
It doesn’t explain why it’s changing though – my guess is … is not the same control. Chances are for some reason you control generation routine is running twice or smt like that.
Put a breakpoint where the control is genretated and see if it gets hit twice – If so, there you go, that’s your problem.