[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:
Dim TN As Label = Me.ReportDetailsZone.FindControl("TeacherName".ToString)
TN.Text = "This is how to add text to a control in a webzone."
TN.Dispose()
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.
Re: [2005] Need help accessing control in webzone
VB Code:
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.
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?
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?