...

View Full Version : Finding HTML Controls in Master-Page environments?



HaloMan
09-26-2007, 01:38 PM
I'm trying to locate an HTML TextArea control from the Codebehind of my app.
The problem is im using a master page and thus finding it in the page hierarchy is proving a bit of a problem.

I've tried:

target = CType(Master.FindControl("Content1").FindControl("TA1"), HtmlControls.HtmlTextArea)

Where Content1 is the name of the ContentPlaceholder and TA1 is the ID assigned to the Html textarea, but I just get a object reference error.
Ive tried Page.FindControl(), Page.Master.FindControl(), this.FindControl() and just findControl, but I just cannot seem to get hold of the damn textbox.
Can anyone assist in how I reference a plan html textarea from the codebehind. I have just the runat=server because im applying some client-side javascript which doesn’t function when I do that, so I need to find the client control from the code-behind;


Thanks

nikkiH
09-26-2007, 02:16 PM
That depends on if the textarea is inside another control, such as a GridView.
And this post would do better in the ASP.NET forum. This forum is for classic ASP. :)

HaloMan
09-26-2007, 06:00 PM
No, its not inside any other control.

The description of this forum is "Talk about ASP and ASP.net here." (just noticed that was an extra .net forum too. why?)

nikkiH
09-26-2007, 10:37 PM
No, its not inside any other control.


Okay, then let's take it one step at a time. Try first to find that placeholder.
Do you get anything for
Master.FindControl("Content1")

Check out this link and see if it helps.
http://msdn2.microsoft.com/en-us/library/xxwa0ff0.aspx



The description of this forum is "Talk about ASP and ASP.net here." (just noticed that was an extra .net forum too. why?)
Don't look at me, I didn't do it. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum