473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
10 2409
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 #2
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
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
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
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
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
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
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 Español : 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
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 Español : 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
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 Español : 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gomaw Beoyr | last post by:
Two question about the "partial classes" (in the next wersion of ..NET). Question 1 ========== Will partial classes (in the next version of C#) have to be declared "partial" in ALL places. ...
21
by: nospam | last post by:
Ok, I asked this question before and I also looked at the book "First Look at ASP.NET 2.0" I also read Paul wilson's web page explanation. HOWEVER...... The book and that web page talks about...
7
by: Patrick | last post by:
Hi all, I was playing around with ASP.Net 2.0 and recognized that in case you use Code-Behind/Beside (how is it called in future?) the parser still creates TWO classes one partial class under...
2
by: Bishoy George | last post by:
In a web application using asp.net 2.0 All my classes are partial classes. - I noticed that partial class cannot be inherited... is that true? - I tried to remove the partial keyword , and I...
9
by: Fat Elvis | last post by:
I'd like to extend some of my Asp.net pages by using Partial Classes. Example ASP.Net Page: public partial class Admin_Customer : System.Web.UI.Page { protected void Page_Load(object sender,...
0
by: John Mott | last post by:
Hello all, I'm trying to break up a large CodeFile .cs file into multiple pieces using partial classes. I'm getting compiler errors which act as if it didn't merge the multiple files. in...
10
by: Phil Townsend | last post by:
Hello, I have come to like just about everything in VS2005 except for the "partial class" feature. Sometimes when I add a control to a web form, it is not referenced in the partial class ....
5
by: Sagar | last post by:
I am working on a migration project for a huge asp.net application now running in framwework 1.1 to dotnet 2.0 As a first step, I opened the .sln files of the project in VS.Net 2005. The...
0
by: Samuel R. Neff | last post by:
We're migrating our .NET 1.1 web application to .NET 3.5 and during conversion we clicked "Convert to Web Application" on the web project. The results from this conversion were inconsistent. 1. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.