page inheritance

  • Thread starter Invalidlastname
  • Start date
I

Invalidlastname

Hi,
I just read the pattern "Design and Implementation Guidelines for Web
Clients" from MSDN.
Here is my question. In chapter 3,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp ,
the article mentions using page inheritance to maintain common page layout.

We currently use page inheritance approach to segment the function areas. In
each function area, there is a base page to provide the common
implementations for that function area, such as access control, rendering
header. There is also a master page which inherits the base page to load
different user controls based on different requests.

However, we cannot implement page inheritance without having the server-side
include files, which contain some common asp.net and html tags shared by all
aspx . By looking at Fig. 3.9, it is not very clear to me how the common
page elements, e.g. header, footer navigation areas were added to the pages
which extends the base page. My understanding of the asp.net page
inheritance is to use shared service-side include for asp.net pages (.aspx),
and base page class for code-behind (.aspx.cs).

Am I missing anything here?




I
 
H

Hermit Dave

Any web page... inherits from the Page Class.....
if you are using code behind... you created a Derived class
the aspx is the final in the inheritance loop in that case.
CodeBehind class inherit Page class
ASPX page (again compiled to a class) inherits from CodeBehind class

now what you can do as per my understanding is create a derived class in
which inherits from Page
and from which your code behind (you can have all of you code behind inherit
from this one)

Yes you are right to an extent when you say that you dont have any server
side includes... like header... footer... etc
but what you have in replacement is User controls... Plus those headers and
footers in user controls and use the user controls as child controls to the
ASPX page....

You also have something called templated pages... now i havent looked into
what exactly they are but i think they are again used to add custom
requirements and you ASPX class or code behind class inherit from it... look
them up...

HTH

--
Regards,

HD

Invalidlastname said:
Hi,
I just read the pattern "Design and Implementation Guidelines for Web
Clients" from MSDN.
Here is my question. In chapter 3,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp ,
 
K

Kevin Spencer

I can certainly understand your confusion after reading the article you
referenced. The section on using Page Inheritance is pretty darned sketchy.
The clue as to what you're missing can be found in the last line of that
section: "The main disadvantage of using page inheritance is increased
complexity compared to the other options discussed in this section."
Apparently, the author didn't desire to go into any details.

The problem with using Page Inheritance to get common layout of course comes
with the Page Template. With the current version of ASP.Net you can't get
visual inheritance, so all of the layout controls have to do all of the
rendering of their HTML by themselves. And of course you have to deal with
the runat=server form. If you want all of the content in the page to be
inside the form, and you want the form to be inside a Panel or some other
HTML container class, the Panel must begin before the form and end after the
form (in order to contain it).

This can all be done via code in an inherited CodeBehind class, but as the
article stated, it is a complex task.

Server-side includes are procedural in nature rather than object-oriented,
and should be avoided.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Invalidlastname said:
Hi,
I just read the pattern "Design and Implementation Guidelines for Web
Clients" from MSDN.
Here is my question. In chapter 3,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp ,
 
S

Steven Cheng[MSFT]

Hi Invalidlastname,


Thank you for using Microsoft Newsgroup Service. Based on your description,
you want to confirm some concept on the "page ineritance" pattern in
ASP.NET. What you understanded is that when using a base page class, we
need two main roles:
1. Generate the base page class, which is used to be inherited by other
pages.
2. Provide a serverside include, which contains the page's base html layout

Please correct me if I misunderstood your description.

I think your understanding is quite correct. As for the page class, there
is no doubt on it since it provides the base page logic in it and other
pages inherit from it in the code behind page class. As for the "serverside
include", since the ASPX page is finally to be render as the html document
in the browser for user, also all the members in the behind page class has
relations with the html element. So when define a base page class, we need
not only the code logic, but also the display layout features, and the MSDN
has suggest us use the "include" ".inc" to provide the common page class's
html layout which will be include in all the derived page's aspx file. As
for more information on this pattern, you can refer the latest tech
articles on the MSDN which is called "PageController patter":

#About the PageController pattern
http://msdn.microsoft.com/architecture/patterns/DesPageController/

#Implementing Page Controller in ASP.NET
http://msdn.microsoft.com/architecture/patterns/ImpPageController/

Please check out the preceding suggestion. If you have any questions on it,
please feel free to let me know.



Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hi Invalidlastname,


Have you had a chance to try my suggestion? If you have any question,
please feel free to let me know.



Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
I

Invalidlastname

Steven,
Thanks for the response. The Page Controller with server-side includes are
exactly we are implementing for our project.
I read about some new features from asp.net 2.0, and one of them is defining
master page. I think the master page is a great way for implementing the
common looks and feels in the application. Before asp.net 2.0 available, the
server-side includes are good enough for our project. I agree the
server-side include approach is procedural rather than object-oriented, but
if we limit the uses of server-side includes for only holding some
placeholder controls and simple html, them the server-side includes make
application much easier to maintain then repeated html code fragments
everywhere.

ILN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top