ASP.Net .Net 2.0 public static string method in web page

A

A T

Hi.

I got two ASPX pages in VS 2005 .Net 2.0

One code behind is
public partial class C1 : System.Web.UI.Page
{
public static string GetThisPageURL(int ProwordID) { return
ProwordID.ToString(); }
}

Second code behind is
public partial class C2 : System.Web.UI.Page
{
private void MyFunction()
{
string b = C1.GetThisPageURL(5);
}
}

"string b = C1.GetThisPageURL(5); "
This line fails.
Why?

Since this a web project in vs 2005 and .net 2.0 there are no namespases.
Public static stuff should be accessible.

Please help
 
C

Carl Daniel [VC++ MVP]

A said:
Hi.

I got two ASPX pages in VS 2005 .Net 2.0

One code behind is
public partial class C1 : System.Web.UI.Page
{
public static string GetThisPageURL(int ProwordID) { return
ProwordID.ToString(); }
}

Second code behind is
public partial class C2 : System.Web.UI.Page
{
private void MyFunction()
{
string b = C1.GetThisPageURL(5);
}
}

"string b = C1.GetThisPageURL(5); "
This line fails.
Why?

Since this a web project in vs 2005 and .net 2.0 there are no
namespases. Public static stuff should be accessible.

In ASP.NET 2.0 every page is a separate assembly, so C1 is undefined within
page C2. If you need common code, put it in .cs files in your applications
App_Code folder, or build it into a separate assembly that's in your
applications Bin folder.

-cd
 

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