473,569 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ 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 1807
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.componen tmodel

<Category("Styl e")> _
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_Hide r_Clt102_SomeCo ntainer_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.componen tmodel

<Category("Styl e")> _
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_Hide r_Clt102_SomeCo ntainer_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.componen tmodel

<Category("Styl e")> _
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
2506
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 simple, but in VB .NET there is a property ClientID and I get an error, a conflict beetwen my clientID and ClientID of MyBase class aspx code: ****
2
1902
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 "_MyControl1__ctl16". But then, on the final HTML rendered, if you look at the page, the textbox looks like this:
2
2374
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 ID="datefield" type="hidden" Runat="Server" /> Client ID -> <%= datefield.ClientID() %> Unfortunately, this only provides the following error: ...
25
4039
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
1500
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 Client ID of a form field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At least, not without extra work. How did I do this? I...
2
1768
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 buttons. I am doing dynamic HTML which I only know how many buttons and context menu to create on the fly. Next I had written a simple JAvascript...
0
1199
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 clientid , but when i use this second time in same code below, it give correct clientid value. Like if i give this , it will work alright ...
2
2718
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: this.btn.Attributes.Add("onclick", "SetDivder(" + this.divContainer.ClientID + ");");
2
6748
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(); addedControl.ID = "addedControl"; pagerCell.Controls.Add(addedControl);
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.