Cannot acces asp:Label in code behind - Requires object reference

Vindictive

New Member
I don't get it. I added an asp:Label in my aspx. page:\[code\]<asp:Label runat="server" Text="" ID="lblStatus"></asp:Label>\[/code\]then when I try to set the text in the code behind:\[code\]lblStatus.Text = " test";\[/code\], it gives me this error:\[code\]An object reference is required for the non-static field, method, or property 'Utilities_MoveFileTemplate.lblStatus'\[/code\]I am trying to set the label's text in the codehind after a stored procedure has run:\[code\] try { conn.Open(); cmd.ExecuteNonQuery(); lblStatus.Text = "success"; }\[/code\]
 
Back
Top