Intellisense bug ?

G

GD

I have a situation where I have renamed a HTML Label from "Label1" to
"lblResult2 in an aspx page.
However when I write code in the code behind module the control name
"Label1" still appears in the intellisense list and I get the error
"System.NullReferenceException: Object reference not set to an instance of
an object." when I try to access the properties of the lblResults control.

I've searched through MSDN for a solution/bugfix for this without any luck..

Anyone had this before ??

Thanks

Gary
 
W

William F. Robertson, Jr.

Make sure your .aspx side has the id="lblResults" and runat="server"

Then look at the field definitions inside you class.

you should see one that says

protected Label lblResults;

Let me know if that doesn't solve your problem.

bill
(it isn't an intellisense bug)
 
G

GD

In the definitions I have;

Protected Withevents lblResults As System.Web.UI.WebControls.Label

This occurs directly after the empty "InitialiseComponent" Sub and before
the line - Private designerplaceholderDeclaration as System.Object

There were two other declarations there for controls that had been deleted
(manually from the HTML source)

The line causing the error is a debug line in the code-behind module -

Response.Write("Label Value is - " & Me.lblResults.Text)

If I remove that line, then the same error occurs on - Me.lblResults.Text =
sResults.ToString

Thanks for your help

Gary
 
M

Mythran

GD said:
In the definitions I have;

Protected Withevents lblResults As System.Web.UI.WebControls.Label

This occurs directly after the empty "InitialiseComponent" Sub and before
the line - Private designerplaceholderDeclaration as System.Object

There were two other declarations there for controls that had been deleted
(manually from the HTML source)

The line causing the error is a debug line in the code-behind module -

Response.Write("Label Value is - " & Me.lblResults.Text)

If I remove that line, then the same error occurs on - Me.lblResults.Text =
sResults.ToString

Thanks for your help

Gary

Double-check the html for this label. Also, you said it was an html label, make
sure that it has runat="server" attribute associated with it as well. And double
check the id of the html label in the html portion.

Mythran
 
S

Scott Mitchell [MVP]

I have a situation where I have renamed a HTML Label from "Label1" to
"lblResult2 in an aspx page.

Just a thought, but did you make the change in the HTML view or the
Design view? If you made the change in the HTML view, go to the Design
view. I've had to do this to get the Code-Behind to update the member
variable name properly...

hth

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
G

GD

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top