Partial class problem


P

Phil Barber

I have two web pages in a VS 2005 project. the first page has a struct
defined and used in the partial class:

public partial class InterIndex : System.Web.UI.Page
{
public struct TXMLData
{
public int DataID;
public string FileName;
public string FilePath;
public string Category;
public string DestLinkText;
public string DestIcon;
}
..........

in the second web page I want to use this same structure; it has code like
this:

public partial class InterIndex : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
....
for (int i = d;i>=0;i--)
{
TXMLData nData= (TXMLData)NewsData;
UpdatesLinksLabel.Text+=nData.FileName+" - ";
}
........

}
}

the files have the same partial class (InterIndex) but the second page gives
me errors on missing namespace or directive for the TXMLData structure. if
they share the partial class why can't the structure definition be seen?
thanks
Phil barber
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

I have two web pages in a VS 2005 project. the first page has a struct
defined and used in the partial class:

the files have the same partial class (InterIndex) but the second page gives
me errors on missing namespace or directive for the TXMLData structure. if
they share the partial class why can't the structure definition be seen?

Are they *actually* the same partial class, or are they in different
namespaces? It sounds very odd to create two partial files for the
same partial class for two pages: don't you need Page_Load in the
first page, for instance?

Jon
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Phil Barber said:
I have two web pages in a VS 2005 project. the first page has a struct
defined and used in the partial class:
the files have the same partial class (InterIndex) but the second page
gives me errors on missing namespace or directive for the TXMLData
structure. if they share the partial class why can't the structure
definition be seen?
thanks
Phil barber

Is this a web app or a website?

Are both "pieces" in the same folder?

website has some weird logic regarding namespaces and where you can put your
stuff.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,
the files have the same partial class (InterIndex) but the second page
gives me errors on missing namespace or directive for the TXMLData
structure. if they share the partial class why can't the structure
definition be seen?
thanks
Phil barber

Sorry for posting again, do this, define a method in both pieces, if they
are correctly treated as the same class you will get an error, if not error
is displayed then you know where the problem is
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top