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

Partial Class for ASPX pages

P: n/a
Hi,
I have problem in creating Partial Class for ASPX pages.
As my Codebase file for ASPX page is having more then 2500 lines of
code. So its very hard to maintain the code. So I wanted to know, how
can I create partial classes to handle this situation OR if I create
new class files in App_Code folder to handle major code of ASPX code
behind page then how can I get the access to the various Web Control
which I have created on the ASPX page???

Please suggest me a way to handle this situation.

Thanks & Regards,
Manoj Singh

Nov 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you have gone beyond maintainability in your ASPX pages, it is time to
move to libraries. While partial classes might be tempting, it is not a wise
direction to improve maintainability.

The first step is to use App_Code and create the classes. Ultimately, you
will want to group like classes and create external libraries. During the
heaviest development cycle, it may not be wise to take this step, but it is
imperative for reusability of code across multiple applications.

Overall, the ASPX page should be a thin veneer over the working code. If you
find more than a few dozen lines of code in a page, your UI is probably
doing too much business rules type of work and needs refactoring.

Here is a good step by step plan
1. Move all repetitive code into functions
2. If you find repeate of functions across pages, move them to a class in
App_Code
3. Once you have all code refactored to class, determine which classes (or
functions) should reside in the same library and move them to an external
project (you can use project references to start).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

********************************************
Think outside the box!
********************************************
"Aryan" <ma*********@gmail.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
Hi,
I have problem in creating Partial Class for ASPX pages.
As my Codebase file for ASPX page is having more then 2500 lines of
code. So its very hard to maintain the code. So I wanted to know, how
can I create partial classes to handle this situation OR if I create
new class files in App_Code folder to handle major code of ASPX code
behind page then how can I get the access to the various Web Control
which I have created on the ASPX page???

Please suggest me a way to handle this situation.

Thanks & Regards,
Manoj Singh
Nov 28 '06 #2

P: n/a
How can you reach 2500 lines of code in a aspx page ?
I'm developping aspx page for 5 years and I never rich a so huge page.

I presume all of your business process is code directly in the pages.
Try to isolate your processes in as many classes as you need, and even in
separated assemblies.

You will gain not only readability but also scalling and maintenability of
your code.

Steve

"Aryan" <ma*********@gmail.coma écrit dans le message de news:
11**********************@h54g2000cwb.googlegroups. com...
Hi,
I have problem in creating Partial Class for ASPX pages.
As my Codebase file for ASPX page is having more then 2500 lines of
code. So its very hard to maintain the code. So I wanted to know, how
can I create partial classes to handle this situation OR if I create
new class files in App_Code folder to handle major code of ASPX code
behind page then how can I get the access to the various Web Control
which I have created on the ASPX page???

Please suggest me a way to handle this situation.

Thanks & Regards,
Manoj Singh

Nov 28 '06 #3

P: n/a
Thanks for your help, what I am doing is binding my various ASP.NET
controls to the respective datasource. In code behind file I am binding
control as given below..Since I am having various ASP.NET controls in
my ASPX page and their properties are getting set in CodeBehind file
and because of this the page size is getting larger and larger.. So I
just wanted to know, if I create seperate Class files to handle these
property settings then how can I access the ASP.NET controls in those
seperate Class files.

As in given below example if I have dropdown control called
(ddCTROrganization) in ASPX page then how can I access this
(ddCTROrganization) control in any other Class files.

For examle.
If Not IsNothing(dvOrgList) Then
ddCTROrganization.Items.Clear()
ddCTROrganization.DataSource = dvOrgList
ddCTROrganization.DataTextField = "OrgName"
ddCTROrganization.DataValueField = "iIDOrganization"
ddCTROrganization.DataBind()
Else
............
..........
End if

Thanks Again.
Manoj Singh

Nov 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.