Server Side Control ID's

  • Thread starter Lloyd Burley via .NET 247
  • Start date
L

Lloyd Burley via .NET 247

Hoping someone here can help me.

I'm trying to change the ID that gets rendered to the browser for a
server side control

Example:

<asp:panel id="Panel5" runat="server">test</asp:panel>

Renders as:

<div
id="_PageTemplate0_innerHolder__PageTemplate7_ProfileOptions_Panel5">t
est</div>

what I'd like to do is change the ID of the div or any other control
back to it's original value(possibly using the ClientID attribute?),
in this case Panel5. I would like this to happen ONLY if i haven't
set a cssclass on the control, that way I can track which I know to
be unique controls to a page and which aren't.

I would like to use this method for 2 reasons.
1. I use the ID's of controls for CSS layout of unique controls and
classes for non-unique controls.
2. I use a nested control template architecture which is a few levels
deep, as can can probably see, the ID that is output to the browser
is ugly and bloated and not in the spirit of the clean HTML I and my
company try to employ.

If anyone can help me out with this I'd be grateful
 
R

Robert Koritnik

Don't use Panel webcontrol. Use something else. Lets say maybe you should
create some Literal control and you have complete cntrol over its rendering.

the thing why CLR changes to ClientID is that it assures uniqueness of the
IDs on the page.

But beside that you should find some other more usable way to achieve your
goal. Not with ID changes...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top