473,624 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.UI.P age inheritance problem

Dan
I posted a similar post regarding problems with VS.NET
design mode. I fixed that problem (with much thanks to
this newsgroup) but now I have a second problem.

I have created a class called BasePage that inherits from
System.Web.UI.P age so that I can implement a "template"
for all pages in an app. My BasePage class is in a class
library project and there is also a web app in the same
solution that has a project reference back to the class
library.

When I create a new web form in VS.NET, I simply change
the code behind class to inherit from BasePage instead of
System.Web.UI.P age.

Everything works great in most cases: controls on the web
form render correctly and maintain thier state as they
should. The problem is that validation controls don't work
at all. It is as if they don't exist, it just skips the
validation all together. If I modify my code behind so it
doesn't inherit from BasePage, but from System.Web.UI.P age
directly, the validation works fine.

By adding a layer of inheritance, what is throwing this
off?

Is there something I need to add to my BasePage class?

Any help is greatly appreciated!

Here is the (simplified) code from my BasePage.cs:
*************** *************** *************** ************
using System;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;

namespace DDN.ClassLib.Ba seClasses
{
public class BasePage : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l
lblPgTitle;
public PageUtilities pgUtil = new
PageUtilities() ;

public string PgTitle
{
get
{
return ViewState
["PgTitle"] == null ? string.Empty : (string) ViewState
["MsgPgTitle "];
}
set
{
ViewState["PgTitle"] =
value;
lblPgTitle.Text = value;
}
}

protected override void OnInit
(System.EventAr gs e)
{
BuildPage( GenerateHtmlFor m() );
this.DataBind() ;
ddRelTasks.Attr ibutes.Add
("onChange", "RelTask(); ");
base.OnInit(e);
}

private HtmlForm GenerateHtmlFor m()
{
HtmlForm form = new HtmlForm();
form.ID = "Form1";
AddControlsFrom DerivedPage(for m);
return form;
}

private void AddControlsFrom DerivedPage
(HtmlForm form)
{
int count = this.Controls.C ount;
for( int i = 0; i<count; ++i )
{
System.Web.UI.C ontrol
ctrl = this.Controls[0];
form.Controls.A dd( ctrl );
this.Controls.R emove(
ctrl );
}
}
private void BuildPage( HtmlForm form )
{

this.Controls.A ddAt( 0, new
LiteralControl( @"
<html>
<head>
<title>MyPage </title>
<link
rel='stylesheet ' href='/def/inc_style.css' type='text/css'>
</head>
<body>"));

this.Controls.A dd( form );

form.Controls.A ddAt(1, new
LiteralControl( @"
<TABLE WIDTH='1000'
BORDER='1' CELLPADDING='0' CELLSPACING='0' BGCOLOR='white'
ID='Table1'>
<TBODY>
<TR>

<TD VALIGN='top'>

<TABLE WIDTH='100%' BORDER='0' CELLPADDING='0'
CELLSPACING='0' ID='Table2' BGCOLOR='white' >

<TBODY>

<TR class=darkbackc ell>

<TD VALIGN='top'>") );

lblPgTitle = new Label();
form.Controls.A ddAt(8,
lblPgTitle );
form.Controls.A ddAt
(form.Controls. Count, new LiteralControl( @"
</td>

</tr>

</TABLE>

</TD>

</TR>

</TABLE>

<br>

</TD>

</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<TABLE ID='Table9'><TR ><TD
HEIGHT='25' COLSPAN='2' VALIGN='top'></TD></TR></TABLE>
"));

this.Controls.A dd(new
LiteralControl( @"</body></html>"));
}
}
}

Nov 18 '05 #1
0 1367

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

Similar topics

14
12898
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at all obvious in VBA which lacks inheritance. I'm trying the explanation again now. I often find cases where a limited form of inheritance would eliminate duplication my code that seems impossible to eliminate otherwise. I'm getting very...
22
23346
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete examples?
2
2545
by: dan | last post by:
I have created a class called BasePage that inherits from System.Web.UI.Page so that I can implement a "template" for all pages in an app. My BasePage class is in a class library project and there is also a web app in the same solution that has a project reference back to the class library. When I create a new web form in VS.NET, I simply change the code behind class to inherit from BasePage instead of System.Web.UI.Page.
0
892
by: Jure Leskovec | last post by:
Hi! I tried to insert a layer between web form class and System.Web.UI.Page. So I made my own HTMLPage class, wich is derived from System.Web.UI.Page and web form is derived from HTMLPage class Everything is OK, except Session object isn't available (All other asp objects are: Response, Request, Application). If webform class is derived directly from System.Web.UI.Page, it works fine.
5
2042
by: Invalidlastname | last post by:
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...
7
1691
by: tshad | last post by:
I have a control that I am using from Metabuilders that requires you to use: <%@ Page Inherits="MetaBuilders.WebControls.DialogPage" %> How do I inherit my code-behind page or another object that may require an inherit also? Thanks, Tom
4
6729
by: DanG | last post by:
Howdy, On past .NET projects, I only had System.Web.UI.Page forms. One application needed a set of functions to do processing against the Page, Session and Request objects associated with the current Form. I handled this by making a new class (BasePage) which inherits from System.Web.UI.Page. Each form would then inherit from BasePage rather than System.Web.UI.Page. I am now on a project that has both System.Web.UI.Page and
2
2501
by: Peter Michaux | last post by:
Douglas Crockford doesn't seem to like JavaScript's built-in syntax for building new objects based on a prototype object. The constructor function, its prototype property and the "new" keyword all seem very offensive to him. For over a year, Crockford has proposed an alternate way of using prototypes like this function object(o) { function F() {} F.prototype = o; return new F();
3
1380
by: Hillbilly | last post by:
I just deployed using FTP to send .aspx and .cs files alike and discovered the base class I use with Master Pages is apparently causing problems --unidentified at the moment-- but a test page that inherits from System.Web.UI.Page and its MasterPage loads fine. I imagine this context may have occurred for others using a base class and wonder if there is somewhere you might recommend I start to determine why and how to resolve...
0
8246
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8631
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.