Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Content Page - How to find ContentPlaceHolder ID for Master Page?

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
I'm getting a bit miffed over this... I'm using the Master Page and Content Page.

I need to pass WebControl ID from Content Page to JavaScript caller in the Master Page. For this, I need to build a string variable, that way JavaScript can use getElementById to find this WebControl. (I'm using RegisterStartUpScript function).

On CodeBehind in Content Page, I'm able to get Master ID and Web Control ID but I couldn't figure out how to get ContentPlaceHolder ID.

--snip--
this.Master.ClientID
this.btnEmail.ClientID
--snip--

I welcome advice on how to get ContentPlaceHolder.

Thanks...
 
the content place holder is purely a server side concept. it has no meaning on the client. if you want to get a section of dom elements place it in a div, and assign the div an id. this is pure html.
Code:
<asp:contentplaceholder ...>
   <div id="my-placeholder">
      <asp:textbox .../>
      ...
   </div>
</asp:contentplaceholder>
then you can get access to this section of the DOM using
Code:
   var section = document.getElementById('my-placeholder');
or
Code:
   var section = $('#my-placeholder');
if you are using jquery

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
How to get ContentPlaceHolder ID in CodeBehind script.

Then I'll able to build the ID string to pass on to JavaScript.

--snip--
mtl00$RenderBody$txtEmail
--snip--

Master - mt100
ContentPlaceHolder - $RenderBody
Client WebControl - txtEmail

I'm able to build the Master and Client WebControl but not the ContentPlaceHolder.
 
yes, ContentPlaceHolder has no meaning on the client. it's a server side concept.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
In ASP.NET CodeBehind, how do I get ContentPlaceHolder ID? So I can write the CodeBehind script.
 
Never mind!! I'm going to have to hardcode the string instead and hope the website don't break down the road.


string sTxtEmailId = "mt100$RenderBody$" + txtEmail.ClientID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top