R
rn5a
Assume that a Web Form has a TextBox server control whose ID is
*txtName*. Now why can't I do something like this?
<script language="VB" runat="server">
Dim txtName As String = txtName.Text
'other subs & functions come here
</script>
The above code generates the following error pointing to the very
first line within the <script></script> tags:
Object reference not set to an instant of an object.
What causes this error? Is it because at that point, the TextBox
hasn't been created yet on the Form?
*txtName*. Now why can't I do something like this?
<script language="VB" runat="server">
Dim txtName As String = txtName.Text
'other subs & functions come here
</script>
The above code generates the following error pointing to the very
first line within the <script></script> tags:
Object reference not set to an instant of an object.
What causes this error? Is it because at that point, the TextBox
hasn't been created yet on the Form?