473,385 Members | 1,375 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,385 software developers and data experts.

partial classes

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 [no Intellisense]. Before
VS2005 I could simply add my own reference, now I can't. Where can I
find the other "part" of the class? Or even better, is there a way to
disable this feature?

Thanks!
*** Sent via Developersdex http://www.developersdex.com ***
Oct 31 '06 #1
10 1943
On Oct 31, 2:50 pm, Phil Townsend <phil25...@gmail.comwrote:
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 [no Intellisense]. Before
VS2005 I could simply add my own reference, now I can't. Where can I
Why can't you? When I add a web form to my web project, I can expand
the .aspx file by clicking the little plus sign and see the .aspx.cs
file. At the top of the Solution Explorer is a button called "Nest
related files". Does it help if you click that?
find the other "part" of the class? Or even better, is there a way to
disable this feature?
I'm not sure if there is a way to turn off partial classes, but you can
move all your code into a single file if that is what you want and then
just remove the partial declaration.

Chris

Nov 1 '06 #2
Thanks for the reply.

The problem I'm having is locating where the other "part" of the partial
class is. Where does VS put it? Thanks...

*** Sent via Developersdex http://www.developersdex.com ***
Nov 2 '06 #3
Phil Townsend wrote:
Thanks for the reply.

The problem I'm having is locating where the other "part" of the partial
class is. Where does VS put it? Thanks...
Physically it should be in the same folder as the .aspx file. So for
default.aspx, there should be a file called default.aspx.cs.

But like I said, just expand the node in the Solution Explorer and you
can get right to it.

Nov 2 '06 #4
Yes, I understand what you are saying. There is an aspx.cs file coupled
with the webform. However, it is only a "partial" class file. What I
need to know is where the other "part" of the aspx.cs file is stored. In
other words, there are two parts of the "partial" class. Whare are ALL
the various parts of the class [not the web form markup]? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 3 '06 #5
Phil Townsend wrote:
Yes, I understand what you are saying. There is an aspx.cs file coupled
with the webform. However, it is only a "partial" class file. What I
need to know is where the other "part" of the aspx.cs file is stored. In
other words, there are two parts of the "partial" class. Whare are ALL
the various parts of the class [not the web form markup]? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
For a web form, I don't think there *is* another part other than the
page itself. At the top of the .aspx file, you should see that the
page inherits the partial class. So that is one part of the class and
the aspx.cs file contains the other part of the class.

Nov 3 '06 #6
Let me rephrase what I am asking. Where are the definitions for the web
controls that are on the web form? Where are the event handlers defined?
They are NOT in the partial class that is visibly coupled with the
webform.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 3 '06 #7

Phil Townsend wrote:
Let me rephrase what I am asking. Where are the definitions for the web
controls that are on the web form? Where are the event handlers defined?
They are NOT in the partial class that is visibly coupled with the
webform.
I assume you're asking if there is an equivalent in web forms of the
Windows Forms Form.Designer.cs file where all the variables are
instantiated and the events are wired up. I don't think there is.

The handlers will be in the aspx.cs file. To test this what I did was
to drag a button onto the web form. I then double clicked it.

In the .aspx page, it added an OnClick attribute to the asp:button
element.

In the .aspx.cs file it added this method:

protected void Button1_Click(object sender, EventArgs e)
{

}

I don't see any other code. I'm not sure if the code to wire up the
event handler is generated anywhere else (i.e. Button1.OnClick +=
Button1_Click;). I don't think it is, but I may be mistaken. I'm
guessing that it is wired up by ASP.Net when the page is requested.

If there is another file somewhere, I am not aware of it. (Of course
that doesn't mean its not there!!).

Cheers,

Chris

Nov 3 '06 #8
Phil Townsend wrote:
Yes, I understand what you are saying. There is an aspx.cs file coupled
with the webform. However, it is only a "partial" class file. What I
need to know is where the other "part" of the aspx.cs file is stored. In
other words, there are two parts of the "partial" class. Whare are ALL
the various parts of the class [not the web form markup]? Thanks.
The code for the design is not visible in the file list, but you can get
to it eventhough.

If you search for the name of a control in the entire solution, you will
see that it's found not only in your .cs file, but also in a
..Designer.cs file. There's where the other part of the class is.
Nov 6 '06 #9

Göran Andersson wrote:
Phil Townsend wrote:
Yes, I understand what you are saying. There is an aspx.cs file coupled
with the webform. However, it is only a "partial" class file. What I
need to know is where the other "part" of the aspx.cs file is stored. In
other words, there are two parts of the "partial" class. Whare are ALL
the various parts of the class [not the web form markup]? Thanks.

The code for the design is not visible in the file list, but you can get
to it eventhough.

If you search for the name of a control in the entire solution, you will
see that it's found not only in your .cs file, but also in a
.Designer.cs file. There's where the other part of the class is.
In any of my VS2005 Web Sites, I can find NO instances of any file
called *.designer.cs. I don't think they exist.

Nov 7 '06 #10
The *.designer.vb file only exists in windows forms projects.

In the case of web projects, the declarations for the controls hosted
on the web form are written into the HTML code for the page. There
doesn't appear to be a declaration written in the language of the
project(C# or VB) in a corresponding primary partial class definition.
I suspect the primary partial class definition is compiled on the fly
at the time of the request.

If you are simply looking for the declaration of the web control, look
in the code view of the main aspx file.

Looks something like this:

"<asp:Button ID="Button1" runat="server" Style="left: 9px; position:
absolute; top: 392px" Text="Left" Width="50px" />"

Dec 18 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
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. ...
16
by: pawel.pabich | last post by:
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.
10
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...
1
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,...
2
by: Sebastian | last post by:
Hi Everyone, we're currently developing an web-app for insurance company. We've got a long form-flows and view-classes (MVC) of about 2000 lines of code. Is there any possibility to split...
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...
2
by: Peted | last post by:
Hi, im moving a project from vs2005 to vs 2008. is doing so i have come across a compiler error regarding partial classes that i dont understand if anyone can explain it to me please the...
10
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.