473,748 Members | 6,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a way to change the ClientID of a control?

I have a control whose ClientID is used in a number of Javascript routines.
It turned out that the ClientID has a dash (-) in it and breaks the JS. Is
there a way to change the ClientID of that control?
Nov 19 '05 #1
7 1520

"Stoyan Stratev" <no@email.set > a écrit dans le message de news:
eq************* *@tk2msftngp13. phx.gbl...
I have a control whose ClientID is used in a number of Javascript routines.
It turned out that the ClientID has a dash (-) in it and breaks the JS. Is
there a way to change the ClientID of that control?


yes and no :

doing ipt.ID = "newid" in code behind will change the ID, but the name
will still be a built name with the resulting ClientID being of the form :
"parentID1_pare ntID2_newid".

this is apparently needed for ASP.Net to be able to rebuild control
hierarchies out of the postback information.

note that parentID1 will only be present if parent1 is with
runat="server", DOM nodes that are not runat="server" are ignored.
Nov 19 '05 #2
The ClientID should only get underscores, unless you have used a dash in the
ID of the control. ASP.NET uses underscores to concat ID's in the control
hierarchy to create unique ClientID's and colons to create unique form name
attributes (UniqueID).

Are you sure nothing in your control hierarchy has a dash in the ID?

Lars-Erik

"Stoyan Stratev" <no@email.set > wrote in message
news:eq******** ******@tk2msftn gp13.phx.gbl...
I have a control whose ClientID is used in a number of Javascript routines.
It turned out that the ClientID has a dash (-) in it and breaks the JS. Is
there a way to change the ClientID of that control?

Nov 19 '05 #3
This happens in a DotNetNuke environment. I checked the chain of controls
and due to a bug in the DNN core the ID of the grandparent control contains
a dash. So I am pretty much stuck if I cannot modify my ClientID. Modifying
the grandparent's ID has no effect.
Nov 19 '05 #4
Hi again!

DotNetNuke is open source, isn't it? Can you do a search/replace on the
granparent's id and replace the dash with an underscore? (If you use the
binaries only, try getting the source and compile your own version)

L-E

"Stoyan Stratev" <no@email.set > wrote in message
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
This happens in a DotNetNuke environment. I checked the chain of controls
and due to a bug in the DNN core the ID of the grandparent control
contains
a dash. So I am pretty much stuck if I cannot modify my ClientID.
Modifying
the grandparent's ID has no effect.

Nov 19 '05 #5
Stoyan Stratev wrote:
I have a control whose ClientID is used in a number of Javascript
routines. It turned out that the ClientID has a dash (-) in it and
breaks the JS. Is there a way to change the ClientID of that control?


maybe you can change the JS:
instead of something like "document.eleme nts.my-control-with-dashes.value",
use "document.eleme nts["my-control-with-dashes"].value"
Or use getElementByID( "my-control-with-dashes")

Hans Kesting
Nov 19 '05 #6
the problem is that I am distributing a skin object. This means that the
client has the javascript and Dotnetnuke already installed. I cannot modify
them. If I change the DNN core then all users would also have to recompile
the whole system which is not feasable.
It seems that I have to wait for the next release of DNN where they will
have (hopefully) the bug fixed.

"Lars-Erik Aabech" <la******@newsg roup.nospam> wrote in message
news:OM******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi again!

DotNetNuke is open source, isn't it? Can you do a search/replace on the
granparent's id and replace the dash with an underscore? (If you use the
binaries only, try getting the source and compile your own version)

L-E

"Stoyan Stratev" <no@email.set > wrote in message
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
This happens in a DotNetNuke environment. I checked the chain of controls and due to a bug in the DNN core the ID of the grandparent control
contains
a dash. So I am pretty much stuck if I cannot modify my ClientID.
Modifying
the grandparent's ID has no effect.


Nov 19 '05 #7
Sounds like a plan, but check out Hans Kesting's answer to your post.. Might
work :)

L-E

"Stoyan Stratev" <no@email.set > wrote in message
news:eN******** ******@TK2MSFTN GP09.phx.gbl...
the problem is that I am distributing a skin object. This means that the
client has the javascript and Dotnetnuke already installed. I cannot
modify
them. If I change the DNN core then all users would also have to recompile
the whole system which is not feasable.
It seems that I have to wait for the next release of DNN where they will
have (hopefully) the bug fixed.

"Lars-Erik Aabech" <la******@newsg roup.nospam> wrote in message
news:OM******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi again!

DotNetNuke is open source, isn't it? Can you do a search/replace on the
granparent's id and replace the dash with an underscore? (If you use the
binaries only, try getting the source and compile your own version)

L-E

"Stoyan Stratev" <no@email.set > wrote in message
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
> This happens in a DotNetNuke environment. I checked the chain of controls > and due to a bug in the DNN core the ID of the grandparent control
> contains
> a dash. So I am pretty much stuck if I cannot modify my ClientID.
> Modifying
> the grandparent's ID has no effect.
>
>



Nov 19 '05 #8

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

Similar topics

2
1918
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
1780
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 which will allow the dialogs (i.e. the context menu's tables) to be placed at the correct location when
3
1687
by: KCRichards59 | last post by:
I'm trying to change the text in a textbox when I roll over a hyperlink on the page. I know to use the "this.MyHyperlink.Attributes.Add("onMouseOver", "ChangeText()");" but I'm not sure if I'm doing it correctly and I'm not sure how to set up the Javascript in the ASP page. I have 4 different hyperlinks and I wanted to perhaps set it up as a case
3
1204
by: =?Utf-8?B?RXJpY2E=?= | last post by:
I have a lable control in a repeater and 2 link buttons. The lable is named lblCurrentPage and the link buttons are named "Prev" and "Next". Once the page is uploaded and viewed through the browser, all three button id's change. Why is this? I see it has been changed by looking at the source of the web page. I thnk this may be causing a problem in my code because I'm refrencing the controls by the id name I gave them. Is there a way to keep...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.