Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 1st, 2006, 01:01 AM
Authorized User
Join Date: Apr 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;


Similar Threads
Thread Thread Starter Forum Replies Last Post
Partial Class and Web Services in C# rsrika C# 2005 0 March 30th, 2006 11:14 AM
Get all property values of class rrhandle ASP.NET 1.0 and 1.1 Basics 1 January 12th, 2006 05:13 PM
Access to a property in the class. AyatKh ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2003 11:25 AM
Project.Class.Property. ? Jstmehr4u3 VB How-To 4 June 11th, 2003 03:10 PM
Project.Class.Property.? Jstmehr4u3 Pro VB 6 2 June 11th, 2003 11:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.