Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding HTML Controls in Master-Page environments?

    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

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?)

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Quote Originally Posted by HaloMan View Post
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •