Property access from Class within Partial Class
The below code works until I try to set StateCode equal to the value of the selected value in my dropdown. The dropdown operates and properly fills the lable in the selected index change event call. The error I get when trying to assign a varilable in the new class to the dropdown selected value is:
"Cannot access a nonstatic member of outer type 'Beta001ServiceAreaSelection' via nested type 'Beta001ServiceAreaSelection.ZipCodeRefLocation'
Can you not create a class within a partial class with full access to the partial class component properties? The code below is the entire ...aspx.cs file.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Beta001ServiceAreaSelection : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void refStateCode_SelectedIndexChanged(object sender, EventArgs e)
{
string refState = refStateCode.SelectedValue;
lblrefState.Text = refState;
}
public class ZipCodeRefLocation
{
// private member variables
public string StateCode;
// ZipCode lookup and Lat / Long assignment method
public void LatLongLookUp()
{
/* CODE BREAKS HERE - DropDownList is on .aspx page
and I cannot access anything frow within this class
that appears on the aspx page - what am I not getting? */
StateCode = refStateCode.SelectedValue;
}
}
}
|