Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Partial Classes in .net
Posted by
Vipul Kelkar
in
Blogs
|
ASP.NET Programming
on
Oct 12, 2011
Ever wondered why the Code behind file of an ASP.net page has.......a partial class ?
Tweet
852
0
0
Ever wondered why the Code behind file of an ASP.net page has.......a partial class ?
public
partial
class
_Default
: System.Web.UI.
Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
}
This is because the class is spread across the Designer file and the code behind file of the ASP.net page. When we drag and drop a control on the designer page of an aspx page, it is directly accessible with its ID on the code behind page without adding any reference of the control on the code behind page
for ex : lblName.text or txtName.text
This is because of the partial class definition. Which essentially means, the code behind file can access the controls placed on the designer file because of the partial class definition
So what is a partial class ?
A class definition can be split across two or more source files. Each file contains a part of the definition of the class. This can be done using the partial keyword
Class definition in one file :
public
patial
class
Employee
{
string
firstname;
string
lastname;
int
age;
string
address;
}
Class definition in another file :
public
partial
class
Employee
{
public
float
getFullName()
{
}
}
Partial classes help us improve the readability of the code. In case of large class definitions we can split the class into several files and place the methods and variables of that class in the files where they are used.
share this blog :
Using Web Configuration Transfor..
How To: Hiding a Column in a DataBound GridView
Related Blogs
Paging in datalist using PagedDataSource class
Video AR002 (Arabic): Sending Mails in ASP.NET
USING EXTENSION METHODS FOR GENERAL FUNCTIONALITIES
.NET Rants
.Net Developer
Diffrence Between Custom Control and User Control
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Work with HTTP Handlers
Directory structure Treeview
Treeview control with XML in ASP.NET
Image Thumbnails control in JQuery
Basic facts and Tidbits in .NET Framework
Slider Control in JQuery
Partial Classes in .net
Disable right click using Jquery
Events and Effects in JQuery
View All
Latest Blogs
WebPart Collector or WebPart Finder
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
View All
Sponsored by
Become a Sponsor