By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

2 or more partial classes and an aspx file in asp.net 2.0

P: n/a
Hi

In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
however,
I thought I’d be able to create another class file, call it a partial class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
by the code generator.

However, when i try this, the 3rd .cs file doesn't even seem to compile, and
any
methods contained therein are not visible by the 1st .cs file, or anything
else
for that matter.

If I try 3 partial classes that aren’t part of an aspx then things work as
expected.

So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs

Default.aspx and Default.aspx.cs interact as expected.

Default.aspx.cs and Default_aspx.cs both implement partial class Default:
System.Web.UI.Page

like so...

Default.aspx.cs

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestMethod();
}
}

Default_.aspx.cs

public partial class _Default : System.Web.UI.Page
{
public bool TestMethod()
{
return true;
}
}

When i compile the project i get the following error:
Error 1 The name 'TestMethod' does not exist in the current context
C:\Documents and Settings\petert\My Documents\Visual Studio
2005\WebSites\WebSite2\Default.aspx.cs
15 9 C:\...\WebSite2\

If i have a non aspx class, with three parts like so...

Class1.cs
Class1_.cs
Class1__.cs

public partial class Class1
{
public Class1()
{
TestMethod1();
TestMethod2();
}
}

public partial class Class1
{
public bool TestMethod1()
{
return true;
}
}

public partial class Class1
{
public bool TestMethod2()
{
return true;
}
}

All compile and work as expected.

I this a limitation with aspx files, or am I missing something.

If there is a specific asp.net 2.0 newsgroup then apologies, and please
direct me to it.

Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?
Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
re:
So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs
Drop Default_.aspx.cs into the App_Code directory.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"ptass" <pt***@newsgroup.nospam> wrote in message
news:B5**********************************@microsof t.com... Hi

In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
however,
I thought I'd be able to create another class file, call it a partial class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
by the code generator.

However, when i try this, the 3rd .cs file doesn't even seem to compile, and
any
methods contained therein are not visible by the 1st .cs file, or anything
else
for that matter.

If I try 3 partial classes that aren't part of an aspx then things work as
expected.

So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs

Default.aspx and Default.aspx.cs interact as expected.

Default.aspx.cs and Default_aspx.cs both implement partial class Default:
System.Web.UI.Page

like so...

Default.aspx.cs

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestMethod();
}
}

Default_.aspx.cs

public partial class _Default : System.Web.UI.Page
{
public bool TestMethod()
{
return true;
}
}

When i compile the project i get the following error:
Error 1 The name 'TestMethod' does not exist in the current context
C:\Documents and Settings\petert\My Documents\Visual Studio
2005\WebSites\WebSite2\Default.aspx.cs
15 9 C:\...\WebSite2\

If i have a non aspx class, with three parts like so...

Class1.cs
Class1_.cs
Class1__.cs

public partial class Class1
{
public Class1()
{
TestMethod1();
TestMethod2();
}
}

public partial class Class1
{
public bool TestMethod1()
{
return true;
}
}

public partial class Class1
{
public bool TestMethod2()
{
return true;
}
}

All compile and work as expected.

I this a limitation with aspx files, or am I missing something.

If there is a specific asp.net 2.0 newsgroup then apologies, and please
direct me to it.

Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?

Nov 19 '05 #2

P: n/a
the problem is there is no way to tell the asp.net compiler to include the
third file with an aspx page. each page is built into its own dll, the aspx
page has in the page directive then name of the codebehind file (see
CodeFile=""), so the two files are compiled into the same assembly.

the files in app_code dir are all compiled into one assembly, so you can use
3 files here.
-- bruce (sqlwork.com)


"ptass" <pt***@newsgroup.nospam> wrote in message
news:B5**********************************@microsof t.com...
Hi

In asp.net 2.0 an aspx files .cs file is a partial class and all works
fine,
however,
I thought I'd be able to create another class file, call it a partial
class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
by the code generator.

However, when i try this, the 3rd .cs file doesn't even seem to compile,
and
any
methods contained therein are not visible by the 1st .cs file, or anything
else
for that matter.

If I try 3 partial classes that aren't part of an aspx then things work as
expected.

So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs

Default.aspx and Default.aspx.cs interact as expected.

Default.aspx.cs and Default_aspx.cs both implement partial class Default:
System.Web.UI.Page

like so...

Default.aspx.cs

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestMethod();
}
}

Default_.aspx.cs

public partial class _Default : System.Web.UI.Page
{
public bool TestMethod()
{
return true;
}
}

When i compile the project i get the following error:
Error 1 The name 'TestMethod' does not exist in the current context
C:\Documents and Settings\petert\My Documents\Visual Studio
2005\WebSites\WebSite2\Default.aspx.cs
15 9 C:\...\WebSite2\

If i have a non aspx class, with three parts like so...

Class1.cs
Class1_.cs
Class1__.cs

public partial class Class1
{
public Class1()
{
TestMethod1();
TestMethod2();
}
}

public partial class Class1
{
public bool TestMethod1()
{
return true;
}
}

public partial class Class1
{
public bool TestMethod2()
{
return true;
}
}

All compile and work as expected.

I this a limitation with aspx files, or am I missing something.

If there is a specific asp.net 2.0 newsgroup then apologies, and please
direct me to it.

Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?

Nov 19 '05 #3

P: n/a
This doesn't fix the problem.
I still get the error that the test method doesnt exist in the current
context.

"Juan T. Llibre" wrote:
re:
So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs


Drop Default_.aspx.cs into the App_Code directory.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"ptass" <pt***@newsgroup.nospam> wrote in message
news:B5**********************************@microsof t.com...
Hi

In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
however,
I thought I'd be able to create another class file, call it a partial class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
by the code generator.

However, when i try this, the 3rd .cs file doesn't even seem to compile, and
any
methods contained therein are not visible by the 1st .cs file, or anything
else
for that matter.

If I try 3 partial classes that aren't part of an aspx then things work as
expected.

So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs

Default.aspx and Default.aspx.cs interact as expected.

Default.aspx.cs and Default_aspx.cs both implement partial class Default:
System.Web.UI.Page

like so...

Default.aspx.cs

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestMethod();
}
}

Default_.aspx.cs

public partial class _Default : System.Web.UI.Page
{
public bool TestMethod()
{
return true;
}
}

When i compile the project i get the following error:
Error 1 The name 'TestMethod' does not exist in the current context
C:\Documents and Settings\petert\My Documents\Visual Studio
2005\WebSites\WebSite2\Default.aspx.cs
15 9 C:\...\WebSite2\

If i have a non aspx class, with three parts like so...

Class1.cs
Class1_.cs
Class1__.cs

public partial class Class1
{
public Class1()
{
TestMethod1();
TestMethod2();
}
}

public partial class Class1
{
public bool TestMethod1()
{
return true;
}
}

public partial class Class1
{
public bool TestMethod2()
{
return true;
}
}

All compile and work as expected.

I this a limitation with aspx files, or am I missing something.

If there is a specific asp.net 2.0 newsgroup then apologies, and please
direct me to it.

Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?


Nov 19 '05 #4

P: n/a
So it can't be done. ?

"Bruce Barker" wrote:
the problem is there is no way to tell the asp.net compiler to include the
third file with an aspx page. each page is built into its own dll, the aspx
page has in the page directive then name of the codebehind file (see
CodeFile=""), so the two files are compiled into the same assembly.

the files in app_code dir are all compiled into one assembly, so you can use
3 files here.
-- bruce (sqlwork.com)


"ptass" <pt***@newsgroup.nospam> wrote in message
news:B5**********************************@microsof t.com...
Hi

In asp.net 2.0 an aspx files .cs file is a partial class and all works
fine,
however,
I thought I'd be able to create another class file, call it a partial
class
and have
that compile and load as a 3rd partial class. This would be handy so i can
generate
standard code into one of the partial classes, while having my custom code
untouched
by the code generator.

However, when i try this, the 3rd .cs file doesn't even seem to compile,
and
any
methods contained therein are not visible by the 1st .cs file, or anything
else
for that matter.

If I try 3 partial classes that aren't part of an aspx then things work as
expected.

So I have 3 files...

Default.aspx
Default.aspx.cs
Default_.aspx.cs

Default.aspx and Default.aspx.cs interact as expected.

Default.aspx.cs and Default_aspx.cs both implement partial class Default:
System.Web.UI.Page

like so...

Default.aspx.cs

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TestMethod();
}
}

Default_.aspx.cs

public partial class _Default : System.Web.UI.Page
{
public bool TestMethod()
{
return true;
}
}

When i compile the project i get the following error:
Error 1 The name 'TestMethod' does not exist in the current context
C:\Documents and Settings\petert\My Documents\Visual Studio
2005\WebSites\WebSite2\Default.aspx.cs
15 9 C:\...\WebSite2\

If i have a non aspx class, with three parts like so...

Class1.cs
Class1_.cs
Class1__.cs

public partial class Class1
{
public Class1()
{
TestMethod1();
TestMethod2();
}
}

public partial class Class1
{
public bool TestMethod1()
{
return true;
}
}

public partial class Class1
{
public bool TestMethod2()
{
return true;
}
}

All compile and work as expected.

I this a limitation with aspx files, or am I missing something.

If there is a specific asp.net 2.0 newsgroup then apologies, and please
direct me to it.

Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?


Nov 19 '05 #5

P: n/a
i tried your suggestion, but i still get the same error whenever i try to
reference the method from the aspx.cs page.

Also, i don't see an attachment ?

Could you attach or post the working code + specify the location where each
file should sit ?

Thanks alot for your time so far.

"Juan T. Llibre" wrote:
Maybe you should adopt a different naming scheme.

See the attached 3-file.jpg, which shows, with the Class View
and Solution Explorer windows, that the classes placed in App_Code
( person.birth.cs and person.name.cs ) are merged into the Person class
which the person.aspx.cs calls with :

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

person.birth.cs has the following class declaration :

public partial class person

and person.name.cs has the following class declaration :

public partial class person

It works...


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"ptass" <pt***@newsgroup.nospam> wrote in message
news:F6**********************************@microsof t.com...
This doesn't fix the problem.
I still get the error that the test method doesnt exist in the current
context.

"Juan T. Llibre" wrote:
re:
> So I have 3 files...
>
> Default.aspx
> Default.aspx.cs
> Default_.aspx.cs

Drop Default_.aspx.cs into the App_Code directory.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"ptass" <pt***@newsgroup.nospam> wrote in message
news:B5**********************************@microsof t.com...
> Hi
>
> In asp.net 2.0 an aspx files .cs file is a partial class and all works fine,
> however,
> I thought I'd be able to create another class file, call it a partial class
> and have
> that compile and load as a 3rd partial class. This would be handy so i can
> generate
> standard code into one of the partial classes, while having my custom code
> untouched
> by the code generator.
>
> However, when i try this, the 3rd .cs file doesn't even seem to compile, and
> any
> methods contained therein are not visible by the 1st .cs file, or anything
> else
> for that matter.
>
> If I try 3 partial classes that aren't part of an aspx then things work as
> expected.
>
> So I have 3 files...
>
> Default.aspx
> Default.aspx.cs
> Default_.aspx.cs
>
> Default.aspx and Default.aspx.cs interact as expected.
>
> Default.aspx.cs and Default_aspx.cs both implement partial class Default:
> System.Web.UI.Page
>
> like so...
>
> Default.aspx.cs
>
> public partial class _Default : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> TestMethod();
> }
> }
>
> Default_.aspx.cs
>
> public partial class _Default : System.Web.UI.Page
> {
> public bool TestMethod()
> {
> return true;
> }
> }
>
> When i compile the project i get the following error:
> Error 1 The name 'TestMethod' does not exist in the current context
> C:\Documents and Settings\petert\My Documents\Visual Studio
> 2005\WebSites\WebSite2\Default.aspx.cs
> 15 9 C:\...\WebSite2\
>
> If i have a non aspx class, with three parts like so...
>
> Class1.cs
> Class1_.cs
> Class1__.cs
>
> public partial class Class1
> {
> public Class1()
> {
> TestMethod1();
> TestMethod2();
> }
> }
>
> public partial class Class1
> {
> public bool TestMethod1()
> {
> return true;
> }
> }
>
> public partial class Class1
> {
> public bool TestMethod2()
> {
> return true;
> }
> }
>
> All compile and work as expected.
>
> I this a limitation with aspx files, or am I missing something.
>
> If there is a specific asp.net 2.0 newsgroup then apologies, and please
> direct me to it.
>
> Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?


Nov 19 '05 #6

P: n/a
Hi Ptass,

I Agree with Bruce's explanation. For ASPX page, their page class's partial
class file are particualrly specified through the "codeFile" attribute in
@Page directive. Also, the source files in App_Code folder will be compiled
into different assemlies with the Page class's assembly, and the dynamic
compilation time and sequence are also different. So manually provide
additional partial class file for aspx page is not supported naturally.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: 2 or more partial classes and an aspx file in asp.net 2.0
| thread-index: AcXmVUDxW9ivrTZTQjiHYYD7b71cCQ==
| X-WBNR-Posting-Host: 203.58.99.1
| From: "=?Utf-8?B?cHRhc3M=?=" <pt***@newsgroup.nospam>
| References: <B5**********************************@microsoft.co m>
<Ot**************@TK2MSFTNGP09.phx.gbl>
| Subject: Re: 2 or more partial classes and an aspx file in asp.net 2.0
| Date: Thu, 10 Nov 2005 16:17:08 -0800
| Lines: 127
| Message-ID: <03**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357230
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So it can't be done. ?
|
|
|
| "Bruce Barker" wrote:
|
| > the problem is there is no way to tell the asp.net compiler to include
the
| > third file with an aspx page. each page is built into its own dll, the
aspx
| > page has in the page directive then name of the codebehind file (see
| > CodeFile=""), so the two files are compiled into the same assembly.
| >
| > the files in app_code dir are all compiled into one assembly, so you
can use
| > 3 files here.
| >
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| > "ptass" <pt***@newsgroup.nospam> wrote in message
| > news:B5**********************************@microsof t.com...
| > > Hi
| > >
| > > In asp.net 2.0 an aspx files .cs file is a partial class and all
works
| > > fine,
| > > however,
| > > I thought I'd be able to create another class file, call it a partial
| > > class
| > > and have
| > > that compile and load as a 3rd partial class. This would be handy so
i can
| > > generate
| > > standard code into one of the partial classes, while having my custom
code
| > > untouched
| > > by the code generator.
| > >
| > > However, when i try this, the 3rd .cs file doesn't even seem to
compile,
| > > and
| > > any
| > > methods contained therein are not visible by the 1st .cs file, or
anything
| > > else
| > > for that matter.
| > >
| > > If I try 3 partial classes that aren't part of an aspx then things
work as
| > > expected.
| > >
| > > So I have 3 files...
| > >
| > > Default.aspx
| > > Default.aspx.cs
| > > Default_.aspx.cs
| > >
| > > Default.aspx and Default.aspx.cs interact as expected.
| > >
| > > Default.aspx.cs and Default_aspx.cs both implement partial class
Default:
| > > System.Web.UI.Page
| > >
| > > like so...
| > >
| > > Default.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > protected void Page_Load(object sender, EventArgs e)
| > > {
| > > TestMethod();
| > > }
| > > }
| > >
| > > Default_.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > public bool TestMethod()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > When i compile the project i get the following error:
| > > Error 1 The name 'TestMethod' does not exist in the current context
| > > C:\Documents and Settings\petert\My Documents\Visual Studio
| > > 2005\WebSites\WebSite2\Default.aspx.cs
| > > 15 9 C:\...\WebSite2\
| > >
| > > If i have a non aspx class, with three parts like so...
| > >
| > > Class1.cs
| > > Class1_.cs
| > > Class1__.cs
| > >
| > > public partial class Class1
| > > {
| > > public Class1()
| > > {
| > > TestMethod1();
| > > TestMethod2();
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod1()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod2()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > All compile and work as expected.
| > >
| > > I this a limitation with aspx files, or am I missing something.
| > >
| > > If there is a specific asp.net 2.0 newsgroup then apologies, and
please
| > > direct me to it.
| > >
| > > Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?
| >
| >
| >
|

Nov 19 '05 #7

P: n/a
And un naturally :-) ? ie., Is there a workaround ?

"Steven Cheng[MSFT]" wrote:
Hi Ptass,

I Agree with Bruce's explanation. For ASPX page, their page class's partial
class file are particualrly specified through the "codeFile" attribute in
@Page directive. Also, the source files in App_Code folder will be compiled
into different assemlies with the Page class's assembly, and the dynamic
compilation time and sequence are also different. So manually provide
additional partial class file for aspx page is not supported naturally.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: 2 or more partial classes and an aspx file in asp.net 2.0
| thread-index: AcXmVUDxW9ivrTZTQjiHYYD7b71cCQ==
| X-WBNR-Posting-Host: 203.58.99.1
| From: "=?Utf-8?B?cHRhc3M=?=" <pt***@newsgroup.nospam>
| References: <B5**********************************@microsoft.co m>
<Ot**************@TK2MSFTNGP09.phx.gbl>
| Subject: Re: 2 or more partial classes and an aspx file in asp.net 2.0
| Date: Thu, 10 Nov 2005 16:17:08 -0800
| Lines: 127
| Message-ID: <03**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357230
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So it can't be done. ?
|
|
|
| "Bruce Barker" wrote:
|
| > the problem is there is no way to tell the asp.net compiler to include
the
| > third file with an aspx page. each page is built into its own dll, the
aspx
| > page has in the page directive then name of the codebehind file (see
| > CodeFile=""), so the two files are compiled into the same assembly.
| >
| > the files in app_code dir are all compiled into one assembly, so you
can use
| > 3 files here.
| >
| >
| > -- bruce (sqlwork.com)
| >
| >
| >
| >
| > "ptass" <pt***@newsgroup.nospam> wrote in message
| > news:B5**********************************@microsof t.com...
| > > Hi
| > >
| > > In asp.net 2.0 an aspx files .cs file is a partial class and all
works
| > > fine,
| > > however,
| > > I thought I'd be able to create another class file, call it a partial
| > > class
| > > and have
| > > that compile and load as a 3rd partial class. This would be handy so
i can
| > > generate
| > > standard code into one of the partial classes, while having my custom
code
| > > untouched
| > > by the code generator.
| > >
| > > However, when i try this, the 3rd .cs file doesn't even seem to
compile,
| > > and
| > > any
| > > methods contained therein are not visible by the 1st .cs file, or
anything
| > > else
| > > for that matter.
| > >
| > > If I try 3 partial classes that aren't part of an aspx then things
work as
| > > expected.
| > >
| > > So I have 3 files...
| > >
| > > Default.aspx
| > > Default.aspx.cs
| > > Default_.aspx.cs
| > >
| > > Default.aspx and Default.aspx.cs interact as expected.
| > >
| > > Default.aspx.cs and Default_aspx.cs both implement partial class
Default:
| > > System.Web.UI.Page
| > >
| > > like so...
| > >
| > > Default.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > protected void Page_Load(object sender, EventArgs e)
| > > {
| > > TestMethod();
| > > }
| > > }
| > >
| > > Default_.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > public bool TestMethod()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > When i compile the project i get the following error:
| > > Error 1 The name 'TestMethod' does not exist in the current context
| > > C:\Documents and Settings\petert\My Documents\Visual Studio
| > > 2005\WebSites\WebSite2\Default.aspx.cs
| > > 15 9 C:\...\WebSite2\
| > >
| > > If i have a non aspx class, with three parts like so...
| > >
| > > Class1.cs
| > > Class1_.cs
| > > Class1__.cs
| > >
| > > public partial class Class1
| > > {
| > > public Class1()
| > > {
| > > TestMethod1();
| > > TestMethod2();
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod1()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod2()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > All compile and work as expected.
| > >
| > > I this a limitation with aspx files, or am I missing something.
| > >
| > > If there is a specific asp.net 2.0 newsgroup then apologies, and
please
| > > direct me to it.
| > >
| > > Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?
| >
| >
| >
|

Nov 19 '05 #8

P: n/a
re:
And un naturally :-) ?
Read Steven's comment as follows : manually providing an additional partial class file
for an aspx page is not supported, naturally.
re:ie., Is there a workaround ?
No, there isn't.
You can't have two code-behind files for one aspx page.

What you *can* do is :

1. Write utility classes and compile *them* into
assemblies which you can reference in your aspx pages.

This is the way I prefer to handle this need.

2. Use the App_Code folder as a repository for partial classes.
You can place many partial class definitions in separate files in App_Code.
They will all be compiled into a single class.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"ptass" <pt***@newsgroup.nospam> wrote in message
news:29**********************************@microsof t.com... And un naturally :-) ? ie., Is there a workaround ?

"Steven Cheng[MSFT]" wrote:
Hi Ptass,

I Agree with Bruce's explanation. For ASPX page, their page class's partial
class file are particualrly specified through the "codeFile" attribute in
@Page directive. Also, the source files in App_Code folder will be compiled
into different assemlies with the Page class's assembly, and the dynamic
compilation time and sequence are also different. So manually provide
additional partial class file for aspx page is not supported naturally.

Thanks,

Steven Cheng
Microsoft Online Support
| So it can't be done. ?
|
| "Bruce Barker" wrote:
|
| > the problem is there is no way to tell the asp.net compiler to include
the
| > third file with an aspx page. each page is built into its own dll, the
aspx
| > page has in the page directive then name of the codebehind file (see
| > CodeFile=""), so the two files are compiled into the same assembly.
| >
| > the files in app_code dir are all compiled into one assembly, so you
can use
| > 3 files here.
| >
| >
| > -- bruce (sqlwork.com) | > "ptass" <pt***@newsgroup.nospam> wrote in message
| > news:B5**********************************@microsof t.com...
| > > Hi
| > >
| > > In asp.net 2.0 an aspx files .cs file is a partial class and all
works
| > > fine,
| > > however,
| > > I thought I'd be able to create another class file, call it a partial
| > > class
| > > and have
| > > that compile and load as a 3rd partial class. This would be handy so
i can
| > > generate
| > > standard code into one of the partial classes, while having my custom
code
| > > untouched
| > > by the code generator.
| > >
| > > However, when i try this, the 3rd .cs file doesn't even seem to
compile,
| > > and
| > > any
| > > methods contained therein are not visible by the 1st .cs file, or
anything
| > > else
| > > for that matter.
| > >
| > > If I try 3 partial classes that aren't part of an aspx then things
work as
| > > expected.
| > >
| > > So I have 3 files...
| > >
| > > Default.aspx
| > > Default.aspx.cs
| > > Default_.aspx.cs
| > >
| > > Default.aspx and Default.aspx.cs interact as expected.
| > >
| > > Default.aspx.cs and Default_aspx.cs both implement partial class
Default:
| > > System.Web.UI.Page
| > >
| > > like so...
| > >
| > > Default.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > protected void Page_Load(object sender, EventArgs e)
| > > {
| > > TestMethod();
| > > }
| > > }
| > >
| > > Default_.aspx.cs
| > >
| > > public partial class _Default : System.Web.UI.Page
| > > {
| > > public bool TestMethod()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > When i compile the project i get the following error:
| > > Error 1 The name 'TestMethod' does not exist in the current context
| > > C:\Documents and Settings\petert\My Documents\Visual Studio
| > > 2005\WebSites\WebSite2\Default.aspx.cs
| > > 15 9 C:\...\WebSite2\
| > >
| > > If i have a non aspx class, with three parts like so...
| > >
| > > Class1.cs
| > > Class1_.cs
| > > Class1__.cs
| > >
| > > public partial class Class1
| > > {
| > > public Class1()
| > > {
| > > TestMethod1();
| > > TestMethod2();
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod1()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > public partial class Class1
| > > {
| > > public bool TestMethod2()
| > > {
| > > return true;
| > > }
| > > }
| > >
| > > All compile and work as expected.
| > >
| > > I this a limitation with aspx files, or am I missing something.
| > >
| > > If there is a specific asp.net 2.0 newsgroup then apologies, and
please
| > > direct me to it.
| > >
| > > Also, is there a specific newgroup for asp.net 2.0 / vs2005 issues ?
| >
| >
| >
|

Nov 19 '05 #9

P: n/a
Hi Ptass,

Thanks for your response. I'm afraid using Multiple partial class files for
aspx page is not allowed due to the fixed page compilation model. However,
we can alternatively provide a common base page class for our pages'
codebehind class. For example, all the pages which will share some common
functionalities can use one central base page class. Let's call it
"CommonBasePage", then, let all those pages' code behind class inherit from
this common class so that this class's non-private functions can be shared
by those concrete classes. Also, in asp.net 2.0, there is one new
attribute named "CodeFileBaseClass", we can define our common base page 's
class through this attribute, so that the runtime will be able to
dynamically compiled the page's structure and make the Controls references
in concrete pages also available in common base class. For example, here is
an example which use this attribute:
=====common base page class(in App_Code)=========

public partial class CommonBasePage : System.Web.UI.Page
{
protected Label Label1;

public CommonBasePage()
{}

protected virtual void Page_Load(object sender, EventArgs e)
{

Label1.Text = SayHello();
}

public string SayHello()
{
return "Hello CommonBasePage.";
}

}
===========================================

======concrete page aspx==========
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageOne.aspx.cs"
Inherits="CommonPage_PageOne"
CodeFileBaseClass="CommonBasePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label></div>
</form>
</body>
</html>
===============================

=====concrete page code behind==========
public partial class CommonPage_PageOne : CommonBasePage
{

}

=====================

We can see that the Label1 control in concrete page can also be accessible
in base page as long as we define the control reference......

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)





--------------------
| From: "Juan T. Llibre" <no***********@nowhere.com>
| References: <B5**********************************@microsoft.co m>
<Ot**************@TK2MSFTNGP09.phx.gbl>
<03**********************************@microsoft.co m>
<1u**************@TK2MSFTNGXA02.phx.gbl>
<29**********************************@microsoft.co m>
| Subject: Re: 2 or more partial classes and an aspx file in asp.net 2.0
| Date: Mon, 14 Nov 2005 05:17:19 -0400
| Lines: 192
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Original
| Message-ID: <uO**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 222stb33.codetel.net.do 64.32.114.222
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357857
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| re:
| > And un naturally :-) ?
|
| Read Steven's comment as follows :
| > manually providing an additional partial class file
| > for an aspx page is not supported, naturally.
|
| re:
| >ie., Is there a workaround ?
|
| No, there isn't.
| You can't have two code-behind files for one aspx page.
|
| What you *can* do is :
|
| 1. Write utility classes and compile *them* into
| assemblies which you can reference in your aspx pages.
|
| This is the way I prefer to handle this need.
|
| 2. Use the App_Code folder as a repository for partial classes.
| You can place many partial class definitions in separate files in
App_Code.
| They will all be compiled into a single class.
|
|
|
|
|
| Juan T. Llibre, ASP.NET MVP
| ASP.NET FAQ : http://asp.net.do/faq/
| ASPNETFAQ.COM : http://www.aspnetfaq.com/
| Foros de ASP.NET en Espaol : http://asp.net.do/foros/
| ======================================
| "ptass" <pt***@newsgroup.nospam> wrote in message
| news:29**********************************@microsof t.com...
| > And un naturally :-) ? ie., Is there a workaround ?
| >
| > "Steven Cheng[MSFT]" wrote:
| >
| >> Hi Ptass,
| >>
| >> I Agree with Bruce's explanation. For ASPX page, their page class's
partial
| >> class file are particualrly specified through the "codeFile" attribute
in
| >> @Page directive. Also, the source files in App_Code folder will be
compiled
| >> into different assemlies with the Page class's assembly, and the
dynamic
| >> compilation time and sequence are also different. So manually provide
| >> additional partial class file for aspx page is not supported naturally.
| >>
| >> Thanks,
| >>
| >> Steven Cheng
| >> Microsoft Online Support
|
|
| >> | So it can't be done. ?
| >> |
| >> | "Bruce Barker" wrote:
| >> |
| >> | > the problem is there is no way to tell the asp.net compiler to
include
| >> the
| >> | > third file with an aspx page. each page is built into its own dll,
the
| >> aspx
| >> | > page has in the page directive then name of the codebehind file
(see
| >> | > CodeFile=""), so the two files are compiled into the same assembly.
| >> | >
| >> | > the files in app_code dir are all compiled into one assembly, so
you
| >> can use
| >> | > 3 files here.
| >> | >
| >> | >
| >> | > -- bruce (sqlwork.com)
|
| >> | > "ptass" <pt***@newsgroup.nospam> wrote in message
| >> | > news:B5**********************************@microsof t.com...
| >> | > > Hi
| >> | > >
| >> | > > In asp.net 2.0 an aspx files .cs file is a partial class and all
| >> works
| >> | > > fine,
| >> | > > however,
| >> | > > I thought I'd be able to create another class file, call it a
partial
| >> | > > class
| >> | > > and have
| >> | > > that compile and load as a 3rd partial class. This would be
handy so
| >> i can
| >> | > > generate
| >> | > > standard code into one of the partial classes, while having my
custom
| >> code
| >> | > > untouched
| >> | > > by the code generator.
| >> | > >
| >> | > > However, when i try this, the 3rd .cs file doesn't even seem to
| >> compile,
| >> | > > and
| >> | > > any
| >> | > > methods contained therein are not visible by the 1st .cs file, or
| >> anything
| >> | > > else
| >> | > > for that matter.
| >> | > >
| >> | > > If I try 3 partial classes that aren't part of an aspx then
things
| >> work as
| >> | > > expected.
| >> | > >
| >> | > > So I have 3 files...
| >> | > >
| >> | > > Default.aspx
| >> | > > Default.aspx.cs
| >> | > > Default_.aspx.cs
| >> | > >
| >> | > > Default.aspx and Default.aspx.cs interact as expected.
| >> | > >
| >> | > > Default.aspx.cs and Default_aspx.cs both implement partial class
| >> Default:
| >> | > > System.Web.UI.Page
| >> | > >
| >> | > > like so...
| >> | > >
| >> | > > Default.aspx.cs
| >> | > >
| >> | > > public partial class _Default : System.Web.UI.Page
| >> | > > {
| >> | > > protected void Page_Load(object sender, EventArgs e)
| >> | > > {
| >> | > > TestMethod();
| >> | > > }
| >> | > > }
| >> | > >
| >> | > > Default_.aspx.cs
| >> | > >
| >> | > > public partial class _Default : System.Web.UI.Page
| >> | > > {
| >> | > > public bool TestMethod()
| >> | > > {
| >> | > > return true;
| >> | > > }
| >> | > > }
| >> | > >
| >> | > > When i compile the project i get the following error:
| >> | > > Error 1 The name 'TestMethod' does not exist in the current
context
| >> | > > C:\Documents and Settings\petert\My Documents\Visual Studio
| >> | > > 2005\WebSites\WebSite2\Default.aspx.cs
| >> | > > 15 9 C:\...\WebSite2\
| >> | > >
| >> | > > If i have a non aspx class, with three parts like so...
| >> | > >
| >> | > > Class1.cs
| >> | > > Class1_.cs
| >> | > > Class1__.cs
| >> | > >
| >> | > > public partial class Class1
| >> | > > {
| >> | > > public Class1()
| >> | > > {
| >> | > > TestMethod1();
| >> | > > TestMethod2();
| >> | > > }
| >> | > > }
| >> | > >
| >> | > > public partial class Class1
| >> | > > {
| >> | > > public bool TestMethod1()
| >> | > > {
| >> | > > return true;
| >> | > > }
| >> | > > }
| >> | > >
| >> | > > public partial class Class1
| >> | > > {
| >> | > > public bool TestMethod2()
| >> | > > {
| >> | > > return true;
| >> | > > }
| >> | > > }
| >> | > >
| >> | > > All compile and work as expected.
| >> | > >
| >> | > > I this a limitation with aspx files, or am I missing something.
| >> | > >
| >> | > > If there is a specific asp.net 2.0 newsgroup then apologies, and
| >> please
| >> | > > direct me to it.
| >> | > >
| >> | > > Also, is there a specific newgroup for asp.net 2.0 / vs2005
issues ?
| >> | >
| >> | >
| >> | >
| >> |
| >>
| >>
|
|
|

Nov 19 '05 #10

P: n/a
Hi Ptass,

Does the suggestion that use a common base page class in my last reply
helps? If there're still anything else we can help, please feel free to
post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 218109604
| References: <B5**********************************@microsoft.co m>
<Ot**************@TK2MSFTNGP09.phx.gbl>
<03**********************************@microsoft.co m>
<1u**************@TK2MSFTNGXA02.phx.gbl>
<29**********************************@microsoft.co m>
<uO**************@tk2msftngp13.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Mon, 14 Nov 2005 12:08:58 GMT
| Subject: Re: 2 or more partial classes and an aspx file in asp.net 2.0
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <Lp**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 237
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:357887
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Ptass,
|
| Thanks for your response. I'm afraid using Multiple partial class files
for
| aspx page is not allowed due to the fixed page compilation model.
However,
| we can alternatively provide a common base page class for our pages'
| codebehind class. For example, all the pages which will share some common
| functionalities can use one central base page class. Let's call it
| "CommonBasePage", then, let all those pages' code behind class inherit
from
| this common class so that this class's non-private functions can be
shared
| by those concrete classes. Also, in asp.net 2.0, there is one new
| attribute named "CodeFileBaseClass", we can define our common base page
's
| class through this attribute, so that the runtime will be able to
| dynamically compiled the page's structure and make the Controls
references
| in concrete pages also available in common base class. For example, here
is
| an example which use this attribute:
|
|
| =====common base page class(in App_Code)=========
|
| public partial class CommonBasePage : System.Web.UI.Page
| {
| protected Label Label1;
|
| public CommonBasePage()
| {}
|
| protected virtual void Page_Load(object sender, EventArgs e)
| {
|
| Label1.Text = SayHello();
| }
|
| public string SayHello()
| {
| return "Hello CommonBasePage.";
| }
|
| }
| ===========================================
|
| ======concrete page aspx==========
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageOne.aspx.cs"
| Inherits="CommonPage_PageOne"
| CodeFileBaseClass="CommonBasePage" %>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml" >
| <head runat="server">
| <title>Untitled Page</title>
| </head>
| <body>
| <form id="form1" runat="server">
| <div>
| <asp:Label ID="Label1" runat="server"
| Text="Label"></asp:Label></div>
| </form>
| </body>
| </html>
| ===============================
|
| =====concrete page code behind==========
| public partial class CommonPage_PageOne : CommonBasePage
| {
|
| }
|
| =====================
|
| We can see that the Label1 control in concrete page can also be
accessible
| in base page as long as we define the control reference......
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
|
|
|
|
|
|
|
|
| --------------------
| | From: "Juan T. Llibre" <no***********@nowhere.com>
| | References: <B5**********************************@microsoft.co m>
| <Ot**************@TK2MSFTNGP09.phx.gbl>
| <03**********************************@microsoft.co m>
| <1u**************@TK2MSFTNGXA02.phx.gbl>
| <29**********************************@microsoft.co m>
| | Subject: Re: 2 or more partial classes and an aspx file in asp.net 2.0
| | Date: Mon, 14 Nov 2005 05:17:19 -0400
| | Lines: 192
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <uO**************@tk2msftngp13.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: 222stb33.codetel.net.do 64.32.114.222
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:357857
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | re:
| | > And un naturally :-) ?
| |
| | Read Steven's comment as follows :
| | > manually providing an additional partial class file
| | > for an aspx page is not supported, naturally.
| |
| | re:
| | >ie., Is there a workaround ?
| |
| | No, there isn't.
| | You can't have two code-behind files for one aspx page.
| |
| | What you *can* do is :
| |
| | 1. Write utility classes and compile *them* into
| | assemblies which you can reference in your aspx pages.
| |
| | This is the way I prefer to handle this need.
| |
| | 2. Use the App_Code folder as a repository for partial classes.
| | You can place many partial class definitions in separate files in
| App_Code.
| | They will all be compiled into a single class.
| |
| |
| |
| |
| |
| | Juan T. Llibre, ASP.NET MVP
| | ASP.NET FAQ : http://asp.net.do/faq/
| | ASPNETFAQ.COM : http://www.aspnetfaq.com/
| | Foros de ASP.NET en Espaol : http://asp.net.do/foros/
| | ======================================
| | "ptass" <pt***@newsgroup.nospam> wrote in message
| | news:29**********************************@microsof t.com...
| | > And un naturally :-) ? ie., Is there a workaround ?
| | >
| | > "Steven Cheng[MSFT]" wrote:
| | >
| | >> Hi Ptass,
| | >>
| | >> I Agree with Bruce's explanation. For ASPX page, their page class's
| partial
| | >> class file are particualrly specified through the "codeFile"
attribute
| in
| | >> @Page directive. Also, the source files in App_Code folder will be
| compiled
| | >> into different assemlies with the Page class's assembly, and the
| dynamic
| | >> compilation time and sequence are also different. So manually
provide
| | >> additional partial class file for aspx page is not supported
naturally.
| | >>
| | >> Thanks,
| | >>
| | >> Steven Cheng
| | >> Microsoft Online Support
| |
| |
| | >> | So it can't be done. ?
| | >> |
| | >> | "Bruce Barker" wrote:
| | >> |
| | >> | > the problem is there is no way to tell the asp.net compiler to
| include
| | >> the
| | >> | > third file with an aspx page. each page is built into its own
dll,
| the
| | >> aspx
| | >> | > page has in the page directive then name of the codebehind file
| (see
| | >> | > CodeFile=""), so the two files are compiled into the same
assembly.
| | >> | >
| | >> | > the files in app_code dir are all compiled into one assembly, so
| you
| | >> can use
| | >> | > 3 files here.
| | >> | >
| | >> | >
| | >> | > -- bruce (sqlwork.com)
| |
| | >> | > "ptass" <pt***@newsgroup.nospam> wrote in message
| | >> | > news:B5**********************************@microsof t.com...
| | >> | > > Hi
| | >> | > >
| | >> | > > In asp.net 2.0 an aspx files .cs file is a partial class and
all
| | >> works
| | >> | > > fine,
| | >> | > > however,
| | >> | > > I thought I'd be able to create another class file, call it a
| partial
| | >> | > > class
| | >> | > > and have
| | >> | > > that compile and load as a 3rd partial class. This would be
| handy so
| | >> i can
| | >> | > > generate
| | >> | > > standard code into one of the partial classes, while having my
| custom
| | >> code
| | >> | > > untouched
| | >> | > > by the code generator.
| | >> | > >
| | >> | > > However, when i try this, the 3rd .cs file doesn't even seem to
| | >> compile,
| | >> | > > and
| | >> | > > any
| | >> | > > methods contained therein are not visible by the 1st .cs file,
or
| | >> anything
| | >> | > > else
| | >> | > > for that matter.
| | >> | > >
| | >> | > > If I try 3 partial classes that aren't part of an aspx then
| things
| | >> work as
| | >> | > > expected.
| | >> | > >
| | >> | > > So I have 3 files...
| | >> | > >
| | >> | > > Default.aspx
| | >> | > > Default.aspx.cs
| | >> | > > Default_.aspx.cs
| | >> | > >
| | >> | > > Default.aspx and Default.aspx.cs interact as expected.
| | >> | > >
| | >> | > > Default.aspx.cs and Default_aspx.cs both implement partial
class
| | >> Default:
| | >> | > > System.Web.UI.Page
| | >> | > >
| | >> | > > like so...
| | >> | > >
| | >> | > > Default.aspx.cs
| | >> | > >
| | >> | > > public partial class _Default : System.Web.UI.Page
| | >> | > > {
| | >> | > > protected void Page_Load(object sender, EventArgs e)
| | >> | > > {
| | >> | > > TestMethod();
| | >> | > > }
| | >> | > > }
| | >> | > >
| | >> | > > Default_.aspx.cs
| | >> | > >
| | >> | > > public partial class _Default : System.Web.UI.Page
| | >> | > > {
| | >> | > > public bool TestMethod()
| | >> | > > {
| | >> | > > return true;
| | >> | > > }
| | >> | > > }
| | >> | > >
| | >> | > > When i compile the project i get the following error:
| | >> | > > Error 1 The name 'TestMethod' does not exist in the current
| context
| | >> | > > C:\Documents and Settings\petert\My Documents\Visual Studio
| | >> | > > 2005\WebSites\WebSite2\Default.aspx.cs
| | >> | > > 15 9 C:\...\WebSite2\
| | >> | > >
| | >> | > > If i have a non aspx class, with three parts like so...
| | >> | > >
| | >> | > > Class1.cs
| | >> | > > Class1_.cs
| | >> | > > Class1__.cs
| | >> | > >
| | >> | > > public partial class Class1
| | >> | > > {
| | >> | > > public Class1()
| | >> | > > {
| | >> | > > TestMethod1();
| | >> | > > TestMethod2();
| | >> | > > }
| | >> | > > }
| | >> | > >
| | >> | > > public partial class Class1
| | >> | > > {
| | >> | > > public bool TestMethod1()
| | >> | > > {
| | >> | > > return true;
| | >> | > > }
| | >> | > > }
| | >> | > >
| | >> | > > public partial class Class1
| | >> | > > {
| | >> | > > public bool TestMethod2()
| | >> | > > {
| | >> | > > return true;
| | >> | > > }
| | >> | > > }
| | >> | > >
| | >> | > > All compile and work as expected.
| | >> | > >
| | >> | > > I this a limitation with aspx files, or am I missing something.
| | >> | > >
| | >> | > > If there is a specific asp.net 2.0 newsgroup then apologies,
and
| | >> please
| | >> | > > direct me to it.
| | >> | > >
| | >> | > > Also, is there a specific newgroup for asp.net 2.0 / vs2005
| issues ?
| | >> | >
| | >> | >
| | >> | >
| | >> |
| | >>
| | >>
| |
| |
| |
|
|

Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.