Mark Rae wrote:
> "senfo" <(E-Mail Removed)-WANT-NO-SPAM> wrote in message
> news:(E-Mail Removed)...
>
>> 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