My page is now looking like this
Sub page_load
if not page.ispostback then
getData()
End Sub
Sub getData()
Read db records
Create dynamic controls
End Sub
Sub saveData()
get dynamic controls info
save results to db
call getData()
End Sub
Now the problem is that in the saveData() i cannot seem to access my dynamic controls anymore using Dim questionQuery As TextBox = questionHolder.FindControl(';questionQuer鈥?The error this throws at me is %26lt;%26lt;Object reference not set to an instance of an object. %26gt;%26gt;.
Does anyone have a clue what this might cause?
Thanks in advance for your time
Greetings
MarkASP.NET cannot find controls which are made in another subroutine?
If you are declaring and creating the controls inside the getDate sub then the controls will only exists while your code is inside that sub. As soon as you leave it, the scope of the application changes and anything done inside the sub is lost.
If you want to have something last throughout execution you will need to declare it at a higher level so that any sub under that level can use it.
You may want to try to create a control class to hold your dynamic controls. That way, you can access the class from inside any sub.ASP.NET cannot find controls which are made in another subroutine?
it looks like the questionholder is null
No comments:
Post a Comment