473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Control ID In Javascript

I'm having problems obtaining the client-side ID in my C# code. I've
tried to access it through the ID, UniqueID and ClientID properties, and
none of them show the entire ID.

The rendered HTML is always ctl00_PageContent_PlaceHolder_.... while
it's always just the plain ID on the server side.

Any ideas?

Thank you in advance,

--
Sean

website: http://senfo.blogspot.com
Jan 26 '07 #1
4 8951
ClientID is the what the rendered id will be.
-- bruce (sqlwork.com)

senfo wrote:
I'm having problems obtaining the client-side ID in my C# code. I've
tried to access it through the ID, UniqueID and ClientID properties, and
none of them show the entire ID.

The rendered HTML is always ctl00_PageContent_PlaceHolder_.... while
it's always just the plain ID on the server side.

Any ideas?

Thank you in advance,
Jan 26 '07 #2
"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:OM**************@TK2MSFTNGP06.phx.gbl...
I'm having problems obtaining the client-side ID in my C# code. I've tried
to access it through the ID, UniqueID and ClientID properties, and none of
them show the entire ID.
If none of them shows the entire ID, what do they actually show...?

..ClientID should show the rendered ID of the control so that e.g. you could
reference it in client-side JavaScript with document.getElementById(...)
The rendered HTML is always ctl00_PageContent_PlaceHolder_.... while it's
always just the plain ID on the server side.
That's correct.
Any ideas?
Not until you actually specify what the problem is...
Jan 26 '07 #3
Mark Rae wrote:
"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:OM**************@TK2MSFTNGP06.phx.gbl...
>I'm having problems obtaining the client-side ID in my C# code. I've tried
to access it through the ID, UniqueID and ClientID properties, and none of
them show the entire ID.

If none of them shows the entire ID, what do they actually show...?
Given the following code, each label displays the text, "SomeValue".

MyControl.ID = "SomeValue";

Label1.Text = MyControl.ID;
Label2.Text = MyControl.UniqueID;
Label3.Text = MyControl.ClientID;
.ClientID should show the rendered ID of the control so that e.g. you could
reference it in client-side JavaScript with document.getElementById(...)
>The rendered HTML is always ctl00_PageContent_PlaceHolder_.... while it's
always just the plain ID on the server side.

That's correct.
>Any ideas?

Not until you actually specify what the problem is...
I except one of those properties to tell me what the *real* client-side
ID is, which is always ctl00_PageContent_PlaceHolder_....

This isn't good because I need it for a JavaScript function.

Example:

Image img = new Image();

img.ImageUrl = "img.png";
img.ID = "MyTest";
img.Attributes.Add("onclick", "MyFunction('" + img.ClientID + "');");

This renders as

<img id="ctl00_PageContent_PlaceHolder_MyTest" src="img.png"
onclick="MyFunction('MyTest');" />

Please note that if anything looks a little strange, it's probably
becaused I typed all of that by hand without Visual Studio.

Thank you again,

--
Sean

website: http://senfo.blogspot.com
Jan 26 '07 #4
senfo wrote:
I'm having problems obtaining the client-side ID in my C# code. I've
tried to access it through the ID, UniqueID and ClientID properties, and
none of them show the entire ID.

The rendered HTML is always ctl00_PageContent_PlaceHolder_.... while
it's always just the plain ID on the server side.

Any ideas?

Thank you in advance,
By the way, it may be important to note that the problem I am
experiencing is in a custom web control that I'm writing.

--
Sean

website: http://senfo.blogspot.com
Jan 26 '07 #5

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

Similar topics

6
by: sck10 | last post by:
Hello, Can you control the window attributes (toolbar, scrollbars, left and right exc.) when using the hyperlink control as you would when using javascript? For examle, I am using the...
3
by: Ant | last post by:
I'm building a Web user control that has several public functions. Can I fire them from the client side? for example Javascript and an HTML button
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
4
by: Neil Stevens | last post by:
Hi, Merry Christmas to you all. I have a problem with server controls, i am writing a C# ASP.NET web project and i am creating custom server controls for some of the more common element. One...
1
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one...
1
by: john conwell | last post by:
I'm using the Browser control to display html that my application generates. Some times i want a javascript to run when the html gets displayed in the browser control, and sometimes i dont. Is...
1
by: rn5a | last post by:
I have created a custom control button which when clicked displays a message in the JavaScript alert dialog. I could successfully compile the VB class file into a DLL & also could add it to the...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
7
by: John Kotuby | last post by:
Hi all, I am trying to use a calendar server control which I have ID="Calendar1" in the source code. What I am trying to do is emulate a JavaScript calendar that was being used in an older ASP...
4
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.