I add a label to a page and set its ID to LabelEditMessage and debug, and there it is. Then in the code behind page (C#) I add a line of code LabelEditMessage.Text="test"; If I build, the build succeeds, but if I press the debug button it does another
build that fails and tells me that LabelEditMessage Does Not Exist in the Current Context. Intellisense knows about it, and I use that to enter the reference to be sure I am not mispelling.
So I tried using FindControl, and that fails with a null reference. It is there, I can see it, but Visual Web Developer refuses to acknowledge it's existence in the code behind file. If I remove the code reference it builds fine and I can see the label
with its default value when i debug, but I cannot reference the label in code.
I'm stumped. It's such a simple thing that I have done many times before. I just don't know what else to try.
I had an almost identical problem once before in the page load event trying to set the ConnectionString property of an SqlDataSource. I tried everything I could think of for days. Then one day I deleted a validator element and it suddenly started working,
and I replaced the validator and it kept on working, so I dismissed it as a fluke. But now it is back, only this time with a label rather than an SqlDataSource. Naturally, I deleted the validator element from the page again, but this time it did not make
the problem go away.
None
0 Points
4 Posts
The name xxx Does Not Exist in the Current Context
Jul 09, 2006 04:49 PM|Tepi|LINK
I add a label to a page and set its ID to LabelEditMessage and debug, and there it is. Then in the code behind page (C#) I add a line of code LabelEditMessage.Text="test"; If I build, the build succeeds, but if I press the debug button it does another build that fails and tells me that LabelEditMessage Does Not Exist in the Current Context. Intellisense knows about it, and I use that to enter the reference to be sure I am not mispelling.
So I tried using FindControl, and that fails with a null reference. It is there, I can see it, but Visual Web Developer refuses to acknowledge it's existence in the code behind file. If I remove the code reference it builds fine and I can see the label with its default value when i debug, but I cannot reference the label in code.
I'm stumped. It's such a simple thing that I have done many times before. I just don't know what else to try.
I had an almost identical problem once before in the page load event trying to set the ConnectionString property of an SqlDataSource. I tried everything I could think of for days. Then one day I deleted a validator element and it suddenly started working, and I replaced the validator and it kept on working, so I dismissed it as a fluke. But now it is back, only this time with a label rather than an SqlDataSource. Naturally, I deleted the validator element from the page again, but this time it did not make the problem go away.
I'm stuck.
Anybody else ever observed a similar problem?