Hajo,
I would like to have 2 my own partial classes.
For example:
Default.aspx.cs
Default2.aspx.cs
and they both will relate to
Default.aspx page.
I have tried to do this in many ways but
I've been unlucky. Any ideas?
thanks in advance for any info
Gawel 16 2618
Hajo,
I use beta 2 of .NET framework.
I can gain desired effect with Windows Forms Application
but I can not do the same with ASP.NET application.
VS.NET seems not to see the additional class let's say
Default2.aspx.cs. I understand the concept of partial classes
but I am not able to use them in web application.
Any ideas?
Gawel
You will have to compile the application to get it to work the way you
desire. By default, each page compiles on the fly. If you follow the default
model, only one partial class can be used per page.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"pa**********@gmail.com" wrote: Hajo,
I would like to have 2 my own partial classes. For example:
Default.aspx.cs Default2.aspx.cs
and they both will relate to Default.aspx page.
I have tried to do this in many ways but I've been unlucky. Any ideas?
thanks in advance for any info
Gawel
re: VS.NET seems not to see the additional class let's say Default2.aspx.cs
Default2.aspx.cs is not a class.
It's a code-behind source file.
Specific sample code to implement partial classes in C# is at : http://msdn2.microsoft.com/library/wa80x488.aspx
Try using the sample code as provided in that page.
Then, maybe, you can adapt it to your needs.
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
<pa**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Hajo,
I use beta 2 of .NET framework. I can gain desired effect with Windows Forms Application but I can not do the same with ASP.NET application. VS.NET seems not to see the additional class let's say Default2.aspx.cs. I understand the concept of partial classes but I am not able to use them in web application.
Any ideas?
Gawel
You mean, that I need to change compilation model? Anyway is it
possible
to gain this effect directly from VS.NET? If so then can you let me
knwo how?
cheers
Gawel
> Default2.aspx.cs is not a class
I can not agree. If it is not a class then what is it? Of course it is
partial class
but it is class anyway.
I know that all I need to do is to compile both classes into one
assembly. But If I
put Default2.aspx.cs along with Default.aspx.cs then compiler does not
see it.
I can put rubbish inside of it and I will get no compilation error. If
I put it into App_code then this class will be compiled into seperate
assembly and won't be merged with Default.aspx.cs. Any idea?
cheers
Pawel
re: Default2.aspx.cs is not a class
I can not agree. If it is not a class then what is it?
Let's not get bogged down in semantics.
re:Any idea?
Before you can take advantage of the partial class compilation model,
you must *mark* the classes as partial.
Take a look at ASP.NET 2.0 Internals : http://msdn.microsoft.com/library/de.../internals.asp
There's sample code there.
Make sure your code conforms with the sample code shown.
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
<pa**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... Default2.aspx.cs is not a class
I can not agree. If it is not a class then what is it? Of course it is partial class but it is class anyway.
I know that all I need to do is to compile both classes into one assembly. But If I put Default2.aspx.cs along with Default.aspx.cs then compiler does not see it. I can put rubbish inside of it and I will get no compilation error. If I put it into App_code then this class will be compiled into seperate assembly and won't be merged with Default.aspx.cs. Any idea?
cheers
Pawel
Ok, maybe I haven't been precise enough. I marked them both with
partial keyword.
Anyway I enclose their content:
// First file Default.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
}
// second file Default2.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
}
}
The compilation model has changed such that the code- behind files do
not compile at the same time. In 1.x we would have compiled them all
together into one assembly in the bin directory.
The runtime is going to generate code for the ASPX file, and compile
that generated code (which includes one partial class) with the source
code referenced by the CodeFile attribute in your @ Page directive.
Any other code files will be ignored when that happens, and it's
possible that the code for each web form will end up in a distinct
assembly.
--
Scott http://www.OdeToCode.com/blogs/scott/
On 1 Sep 2005 06:12:23 -0700, pa**********@gmail.com wrote: Ok, maybe I haven't been precise enough. I marked them both with partial keyword. Anyway I enclose their content:
// First file Default.aspx.cs public partial class _Default : System.Web.UI.Page {
protected override void OnLoad(EventArgs e) { base.OnLoad(e); } }
// second file Default2.aspx.cs public partial class _Default : System.Web.UI.Page { protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); }
}
It means that I can not use "my own" partial classes in asp.net?
I can compile every directory as separate assembly but
it doesn't help because my second class is still ignored.
anyway thank for info
Gawel
You can write your own partial classes all day long with the .Net Platform
2.0.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
<pa**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... It means that I can not use "my own" partial classes in asp.net? I can compile every directory as separate assembly but it doesn't help because my second class is still ignored.
anyway thank for info
Gawel
Hajo,
Kevin, did you read the whole thread?
It is about .NET 2.0 and in short that I can not use more then one code
behind files.
I would like to have my code behind in two files. Do you know how to
achive this effect ?
Gawel
See Juan's reply.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
<pa**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com... Hajo,
Kevin, did you read the whole thread? It is about .NET 2.0 and in short that I can not use more then one code behind files. I would like to have my code behind in two files. Do you know how to achive this effect ? Gawel
I believe Pawel is trying to split his code-behind partial class
across multiple files. As far as I know this isn't possible, unless
the CodeFile attribute lets you reference multiple files for an ASPX
page. The runtime only compile the partial class it creates, and the
one partial class referenced by CodeFile - everything else will be
left out in the cold.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 2 Sep 2005 11:31:14 -0400, "Juan T. Llibre"
<no***********@nowhere.com> wrote: Pawel,
Attached are 4 images.
1. Classes-partial.jpg - shows all source files 2. Class.person.birth.jpg - shows contents of partial class person.birth.cs
public partial class person { public int Age; public DateTime Birth; }
3. Class.person.name.jpg - shows contents of partial class person.name.cs public partial class person { public string FirstName; public string LastName; }
4. ClassView.jpg - Show *all* members of the person class : int Age, DateTime Birth, string FirstName and string LastName
Clearly, all members in both partial classes are seen as part of *one* class : the person class.
Partial classes *do* work in Beta 2 and later builds of VS.NET. Juan T. Llibre ASP.NET MVP ASP.NET FAQ : http://asp.net.do/faq/ ===========================
<pa**********@gmail.com> wrote in message news:11**********************@g47g2000cwa.googleg roups.com... Hajo,
Kevin, did you read the whole thread? It is about .NET 2.0 and in short that I can not use more then one code behind files. I would like to have my code behind in two files. Do you know how to achive this effect ? Gawel
re: I believe Pawel is trying to split his code-behind partial class across multiple files.
Maybe we're geting bogged down in semantics here but,
isn't that what the images I sent show ?
person.birth.cs and person.name.cs are
getting compiled into a single *person class*.
Of course, you can't have 2 codebehind pages for the *same* page,
but the objective isn't to split the codebehind like that, so that UI
and codebehind get mixed.
That will not be possible and is not an objective.
The objective is to "containerize" different parts of the same class
into different files, so that -for example- different parts of the same
class can be worked on by different developers without risk of
overwriting code.
See http://msdn.microsoft.com/msdnmag/is...0/default.aspx
From that article :
C# 1.1 requires you to put all the code for a class in a single file.
C# 2.0 allows you to split the definition and implementation
of a class or a struct across multiple files.
You can put one part of a class in one file and another part of the class
in a different file, noting the split by using the new partial keyword.
In fact, you can have as many parts as you like in any given class. Partial type support
is available for classes, structures, and interfaces, but you cannot have a partial enum
definition.
Partial types are a very handy feature. Sometimes it is necessary to modify
a machine-generated file, such as a Web service client-side wrapper class.
However, changes made to the file will be lost if you regenerate the wrapper class.
Using a partial class, you can factor those changes into a separate file.
ASP.NET 2.0 uses partial classes for the code-beside class
(the evolution of codebehind), storing the machine-generated part of the page separately.
C# 2.0 supports partial types as follows: when the compiler builds the assembly,
it combines from the various files the parts of a type and compiles them into a
single type in Microsoft intermediate language (MSIL).
The generated MSIL has no recollection which part came from which file.
Just like in C# 1.1 the MSIL has no record of which file was used to define which type.
Also worth noting is that partial types cannot span assemblies, and that a type can refuse
to have other parts by omitting the partial qualifier from its definition.
Because all the compiler is doing is accumulating parts, a single file can contain
multiple parts, even of the same type, although the usefulness of that is questionable.
In C#, developers often name a file after the class it contains
and avoid putting multiple classes in the same file.
When using partial types, I recommend indicating in the file name that it contains
parts of a type such as MyClassP1.cs, MyClassP2.cs, or employing some
other consistent way of externally indicating the content of the source file.
end of article quote...
It's the *class* which can be, and gets, split into multiple files,
not the page's codebehind.
Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
==========================
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:8a********************************@4ax.com...I believe Pawel is trying to split his code-behind partial class across multiple files. As far as I know this isn't possible, unless the CodeFile attribute lets you reference multiple files for an ASPX page. The runtime only compile the partial class it creates, and the one partial class referenced by CodeFile - everything else will be left out in the cold.
-- Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 2 Sep 2005 11:31:14 -0400, "Juan T. Llibre" <no***********@nowhere.com> wrote:
Pawel,
Attached are 4 images.
1. Classes-partial.jpg - shows all source files 2. Class.person.birth.jpg - shows contents of partial class person.birth.cs
public partial class person { public int Age; public DateTime Birth; }
3. Class.person.name.jpg - shows contents of partial class person.name.cs public partial class person { public string FirstName; public string LastName; }
4. ClassView.jpg - Show *all* members of the person class : int Age, DateTime Birth, string FirstName and string LastName
Clearly, all members in both partial classes are seen as part of *one* class : the person class.
Partial classes *do* work in Beta 2 and later builds of VS.NET. Juan T. Llibre ASP.NET MVP ASP.NET FAQ : http://asp.net.do/faq/ ===========================
<pa**********@gmail.com> wrote in message news:11**********************@g47g2000cwa.google groups.com... Hajo,
Kevin, did you read the whole thread? It is about .NET 2.0 and in short that I can not use more then one code behind files. I would like to have my code behind in two files. Do you know how to achive this effect ? Gawel
Ok, in short I can't. That's all. But for me it is a little bit strange
because codebehind is just form of partial class and therefore
I should have been able to split my code into many files. But it seems
that it's limitation of ASP.NET.
anyway thanks for hot :) discussion
Pawel Pabich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lionel B |
last post by:
Greetings.
The following code compiles ok and does what I'd expect it to do:
---------- START CODE ----------
// test.cpp
|
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.
...
|
by: ptass |
last post by:
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...
|
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...
|
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,...
|
by: erich |
last post by:
In VS2005, creating a new form creates the form class and a partial
(frm*.designer.vb) class file and displays the partial class beneath
the main
form frm*.vb, which is great. However, when...
|
by: Lau Lei Cheong |
last post by:
A few quick questions:
Is there a limitation on how much partial class files we can have for a
single class? And can a ASP.NET page file inherit a class from multiple
code-behind files? if so,...
|
by: Hiten |
last post by:
Is it possible to have more code behind file but that file will have
same class in way of partial class,
Default
Structure I
--------------
Homepage.aspx
+ Homepage.aspx.cs (this .cs file...
|
by: JDeats |
last post by:
So I have a class that spans over two partial classes in code, here's
an example (do not read much into this, the code is of no practical
use, this is just a simple example of where my confusion...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |