Results 1 to 4 of 4

Thread: [2005] Need help accessing control in webzone

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Location
    Indiana
    Posts
    451

    Question [2005] Need help accessing control in webzone

    I did a search for webzone here, and googled, but couldn't find anything to help.

    I am playing with webzones to get familiar with them, and I am trying to change the text in a label in a webzone on the page load event, but I am getting Object reference not set to an instance of an object.

    Here is my code.

    VB Code:
    1. Dim TN As Label = Me.ReportDetailsZone.FindControl("TeacherName".ToString)
    2.             TN.Text = "This is how to add text to a control in a webzone."
    3.             TN.Dispose()
    4.             TN = Nothing

    I am guessing that my find control code is not finding the control so TN = nothing. I just can't seem to find any code examples to see if I am finding the code wrong, or not.

    Thank you for your help.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Need help accessing control in webzone

    VB Code:
    1. Dim TN As Label = CType(Me.ReportDetailsZone.FindControl("TeacherName"), Label)

    Also, note that saying

    Code:
    "TeacherName".ToString
    is as redundant as sterilizing needles before executions.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2005
    Location
    Indiana
    Posts
    451

    Re: [2005] Need help accessing control in webzone

    Thank you, mendhak, for your reply. I gave it a try, but it didn't work. I got the same error on the line that assigns the text property. I did go back and verify that the id is correct, and it is. Any other ideas?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Need help accessing control in webzone

    My next question would be, is the Label you're looking for inside another control inside the web part control?

Posting Permissions

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



Click Here to Expand Forum to Full Width