ASP.NET Dynamic UserControl ID Generation Issue

I had a problem with changing the identifier property of dynamically loaded UserControls during the page life cycle. In particular, the ID property changes when the system calls Page.Form.RenderControl (htmlTextWriter); Before it is called, the control has the identifier "ctl84", but after the call, it has the identifier "ctl99".

The result from htmlTextWriter contains the original identifier, however, checking the Control ID property in the VS 2008 debugger shows that it has changed.

The application runs in MCMS 2002 (Microsoft CMS 2002), using .NET 2.0, converted from 1.1 and xhtmlConformance = "Legacy" is not included.

I need the ID to be constant throughout the life of the page.

Edit: manually setting the ID property is not an option.

+3
source share
4 answers

Are you explicitly assigning an identifier to the control from code?

If you are an identifier, it must remain the same.

He does not explain why he is changing, although in my opinion this is not the same . Most likely, for some reason you are in control of a generation procedure that runs twice or smt.

Place a breakpoint at which the control is set and see if it hits twice - If so, you go what is your problem.

+1
source

, , , GetHashCode() .

0

asp.net, . , . ClienID, .

btnSave = ();

btnSave.ID = "btnSave";

string clientID = btnSave.ClientID;

cientID, "ctl88_99 _ *** _ btnSave".

0

, , rAm .. . , id .. Andy

0

Source: https://habr.com/ru/post/1706029/


All Articles