Overriding the ClientID

I

Iain

I'm writing a server control which is a navigation bar.

My prototype uses id based styles to control the layout and dynamics.

Is there any way I can override asp.net's processing of the ID so that the
ID will be the one I want regardless of the containing page and so on?

Iain
 
G

Guest

Iain,
I'm sure there is a way to change the id howabout me.id = "Iain1" but it
probably will cause problems with your control working in some environments.
A more structured design approach is to use a custom property in your
control. You get the bonus of having designer support. Make a quick change
to your prototype to include a property for the styles. Store the styles in
an enumeration. Use your new StyleType property to control the navigation
rendering.

imports system.componentmodel

<Category("Style")> _
Public Property StyleType() As st
Get
Return _StyleType
End Get
Set(ByVal value As st)
_StyleType = value
End Set
End Property
Public Enum st As Integer
Space = 1
Earth = 2
Valley = 0
End Enum
Private _StypeType As st = st.Space 'space is default in this example
....
if me.StyleType = st.Space then
' make background black have fun Iain!
....
endif

Good Luck
DWS
 
I

Iain

On Fri, 3 Mar 2006 07:25:27 -0800, DWS wrote:

Thank's for your input DWS.

Unfortunately, that won't quite do what I want.

Me.ID = "Iain" will end up in the html as something link

ID="Ctl100_Hider_Clt102_SomeContainer_Ctl100_Iain"

since the actual ID in the html depends on whereabouts in the control
hierarchy control actually is.

CLientID holds this value but it's read only.

One sort of work around is to use a named class rather than an ID based
class in the style sheet (that is add class="MyClass") and set this in the
control. This would work, but there's some risk of accidental collisions
(ID's must be unique but classes need not be).

In the end (for now, anyway), I've bypassed all the cleverness and coded up
the important bits as raw html in a literal control...

Iain
 
G

Guest

Iain,
Sorry I really wanted to help.

Good Luck
DWS

Spaming group with navigation controls The DWS custom navigation control is
chocked full of custom properties. Just a navigation control on a panel but
it has tooltips, images, and uses a custom sitemap provider. The, alignment,
style properties, fonts and background color can be changed by users at
runtime.

Check it out.
http://www.dws400.com/default.aspx?p=nbaeast
 

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,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top