473,466 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Overriding the ClientID

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
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk
Mar 2 '06 #1
3 1802
DWS
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
"Iain" wrote:
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
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk

Mar 3 '06 #2
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
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
"Iain" wrote:
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
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk

--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk
Mar 3 '06 #3
DWS
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
"Iain" wrote:
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
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
"Iain" wrote:
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
--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk

--
Iain Downs (DirectShow MVP)
Commercial Software Therapist
www.idcl.co.uk

Mar 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Maras | last post by:
Hello, as we know VB is not case sensivity. I have a following problem, I have to send to another server few parametrs by post or get method, one of them MUST be a "clientID", it's preety...
2
by: kw | last post by:
TextBox t=new TextBox(); Controls.Add(t); t.ID=t.ClientID; //reads: "_MyControl1__ctl16" And even in OnPreRender, I examine the Controls collection and verify that the ID of the TextBox is...
2
by: Neo Geshel | last post by:
I need to get the ClientID of a form field for some JavaScript. About 25+ web sites I visited recommend the following method for finding the client ID of a web form: Web Form -> <asp:TextBox...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
by: Neo Geshel | last post by:
After pouring over about a dozen sites that clearly dealt with ClientID all by itself, I came to the realization that about 2/3+ of them were doing it wrong. It is indeed impossible to grab the...
2
by: JJ | last post by:
Hi, Can anyone advise me how is the ClientID issued? I had a suite Controls which consist of a context menu (i.e. a group of tables, rows and cells situated in a class library) and a set of...
0
by: Vikram | last post by:
is someone has faced this kind of problem... I am using clientid porperty of server control in this manner in a javascript alert('<%=txt.clientid%>') now first time it give some spaces in the...
2
by: davidr | last post by:
I'm reposting hoping to get a reply, my last one got bumped down because I posted in the late day. Hi, I have in my behind code a user control with the following in Page Load: ...
2
by: DC | last post by:
Hi, I am doing something like this in the ItemCreated event (ASP.Net 1.1): DataGridItem pagerRow = e.Item; TableCell pagerCell = pagerRow.Cells; Control addedControl = new Control();...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.