R
Ranginald
This question is about how to handle an .aspx page that references
multiple methods and where to store these methods (e.g. one codefile or
multiple codefiles).
PREFACE
========
I have a simple category/product asp.net/C# web site I am coding in
web dev express and laying out in dreamweaver MX. I find the layout
tools in web express difficult to use and implementation of complex
templates much easier in dwmx.
On my site's primary template page, there is a navigation side bar
comprised of two dropdownlst controls that is in the left margin and
used on every page in the site. This is a locked region on the
template. I use code-behind files so the controls functionality, (eg.
OnSelectedIndexChanged) are referenced in the derived .aspx pages as
OnSelectedIndexChanged=category, OnSelectedIndexChanged=Product. These
work fine.
On the default.aspx page (derived from primary.dwt), there are the same
controls (obviously) and the codebehind file is default.aspx.cs.
Everything to this point works.
THE PROBLEM
============
Once I execute the category dropdownlist (using only one of the
dropdownlists as an example -- the other dll is very similar), and
therefore execute the OnSelectedIndexChanged=category method (the code
for which is in the default.aspx.cs page), the category() method takes
the user to a new page, category.aspx, where the user sees some new
content in the BODY region, and where the same dropdownlists are in
the left margin (because the category.aspx page is basesd on the
primary.dwt template).
Executing the ddl controls on the category.aspx page also works fine
because the code for these methods is in the same default.aspx.cs page,
and the codebehind directive is the same because this page is based on
the primary.dwt file (where the codebehind directive is set).
Sorry for the long preface.
So here are the questions:
======================
1. I need to execute other methods in the main body of the
category,aspx page, independent of the funcitonality of the left-hand
drop down lists.
If this new method, specific to the category.aspx page is called, for
example, newmethod(), should I put this code also into the
default.aspx.cs file, or should I have a separate file, say,
category.aspx.cs in order to keep the code for newmethod() separate?
2. Along those lines, from a "good coding" perspective, it is better
to have all the codebehind in one file (e.g. is that what professional
programmers do?) or is it better to break it up somehow (if that's
possible)? E.g have TWO Codefile="somefile.aspx.cs" directives?
3. Is there a better way to organize this code? It seems that even if
I have a .dll with all the code, and then just reference the
class.method from the .DLL , I still have the same problem of where to
put all the code --- especially when one .aspx page needs to reference
multiple methods?
Thanks in advance for any insight.
-Rangy
multiple methods and where to store these methods (e.g. one codefile or
multiple codefiles).
PREFACE
========
I have a simple category/product asp.net/C# web site I am coding in
web dev express and laying out in dreamweaver MX. I find the layout
tools in web express difficult to use and implementation of complex
templates much easier in dwmx.
On my site's primary template page, there is a navigation side bar
comprised of two dropdownlst controls that is in the left margin and
used on every page in the site. This is a locked region on the
template. I use code-behind files so the controls functionality, (eg.
OnSelectedIndexChanged) are referenced in the derived .aspx pages as
OnSelectedIndexChanged=category, OnSelectedIndexChanged=Product. These
work fine.
On the default.aspx page (derived from primary.dwt), there are the same
controls (obviously) and the codebehind file is default.aspx.cs.
Everything to this point works.
THE PROBLEM
============
Once I execute the category dropdownlist (using only one of the
dropdownlists as an example -- the other dll is very similar), and
therefore execute the OnSelectedIndexChanged=category method (the code
for which is in the default.aspx.cs page), the category() method takes
the user to a new page, category.aspx, where the user sees some new
content in the BODY region, and where the same dropdownlists are in
the left margin (because the category.aspx page is basesd on the
primary.dwt template).
Executing the ddl controls on the category.aspx page also works fine
because the code for these methods is in the same default.aspx.cs page,
and the codebehind directive is the same because this page is based on
the primary.dwt file (where the codebehind directive is set).
Sorry for the long preface.
So here are the questions:
======================
1. I need to execute other methods in the main body of the
category,aspx page, independent of the funcitonality of the left-hand
drop down lists.
If this new method, specific to the category.aspx page is called, for
example, newmethod(), should I put this code also into the
default.aspx.cs file, or should I have a separate file, say,
category.aspx.cs in order to keep the code for newmethod() separate?
2. Along those lines, from a "good coding" perspective, it is better
to have all the codebehind in one file (e.g. is that what professional
programmers do?) or is it better to break it up somehow (if that's
possible)? E.g have TWO Codefile="somefile.aspx.cs" directives?
3. Is there a better way to organize this code? It seems that even if
I have a .dll with all the code, and then just reference the
class.method from the .DLL , I still have the same problem of where to
put all the code --- especially when one .aspx page needs to reference
multiple methods?
Thanks in advance for any insight.
-Rangy