1

I have the following HiddenField in my ASP.NET 2.0 webform:

<asp:HiddenField ID="HiddenModel" runat="server" 
OnValueChanged="HiddenModel_ValueChanged" />

My codebehind references HiddenModel in this if..else statement:

if (serial.Text.ToString() != "0")
{
CarpetMultiView.ActiveViewIndex = 1;
HiddenModel.Value = model.SelectedItem.Text.ToString();
LabelCurrent.Text = "Your Current Selection is :
Make-" + make.SelectedItem.Text.ToString() + " Model-" + 
model.SelectedItem.Text.ToString() + " S/N-" + serial.SelectedItem.Text.ToString();
Page.Title = make.SelectedItem.ToString() + " " + model.SelectedItem.ToString() + " " + 
serial.SelectedItem.ToString() + " " + "Carpet";
}

When I debug the solution using VWD 2005, I receive the following error:

The name 'HiddenModel' does not exist in the current context    

My @Page directive inherits carpet_template which matches the codebehind class:

public partial class carpet_template : System.Web.UI.Page

How can I resolve these and other similar errors?

SidC
  • 3,175
  • 14
  • 70
  • 132

3 Answers3

1

From the link below: "If you are testing in IIS, you should go to the website menu in VWD, click start options, click "build" on the tree in the left pane, and on the dropdown list labelled "Before running startup page" select "No Build".

Full story HERE.

JBrooks
  • 9,901
  • 2
  • 28
  • 32
0

Delete all the backup copies of the same files. I had a backup copy of the same file in same folder, after deleting those backup files - solution is compiling without any errors.

Got this solution from link below: [slash84]
http://forums.asp.net/post/3060379.aspx

NavSG
  • 1
0

Its difficult to be sure when the code is out of context of the page life cycle, but it sounds like asp.net simply doesn't accept that the field currently exists.

The most logical reason is that the hidden field doesn't yet exist in the page life cycle (see page lifecycle) - is the code run before the page has been loaded or before the control has been rendered?

Alternatively if there is a problem with the form you could get this behaviour (eg if the hidden field is not within the form tags).

amelvin
  • 8,919
  • 4
  • 38
  • 59