[MonoDevelop] variables that don't exist in current context

Devin Venable venable.devin at gmail.com
Fri Aug 27 15:01:40 EDT 2010

I'm porting an ASP.NET project on Windows to mono/Linux in
MonoDevelop.  I'm still a newbie when it comes to ASP.NET.

On Windows, the project was a "web site" and I'm making it a "web
application" by importing everything into an empty project.

For each aspx file (web template) there is one ascs.cs file (the
associated code).

For every field that is in the aspx like this:

<asp:RequiredFieldValidator ID="rfvQ1" runat="server"
         Display="Dynamic" ErrorMessage="Required.<br>" InitialValue="
<asp:DropDownList ID="ddlQuestion1" runat="server">

There is a reference in the c# like this where it is used:

 rfvAnswer1.ErrorMessage = msgRequired;

The problem:  When I compile I get:

Error CS0103: The name `rfvAnswer1' does not exist in the current
context (CS0103) (GTPCard)

It's because the rfvAnswer variable hasn't been explicitly declared.
If I add a protected member to the class like this:

protected System.Web.UI.WebControls.RequiredFieldValidator rfvAnswer1;

...the error goes away.

The question is WHY am I having to do this over and over again for
every reference?  Is there a reference I can include, or a way to
configure the project so that the variables are automatically created?

I assume something must be happening like this on the Windows/Visual
Studio side, since there the project source doesn't have these
variables explicitly created.

More information about the Monodevelop-list mailing list