471,066 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Inheritance / Webform / IDE problem

I am having a problem with inheritance for my web solution.

Here are the steps I took for a project within C#:

-I first created a new class, descended from System.Web.UI.Page. For
this description, let's call this class "MyBasePage". Every webform
page within my solution will descend from this class instead of
System.Web.UI.Page. The reason for this is so that I have a common
base class from which I can put custom validation, formatting, and
messaging functionality for all of my pages. This base class does not
have a corresponding .aspx page since each page will be formatted

-Within that class, I declare a System.Web.UI.WebControls.Label
variable named "Msg". The purpose of this object is to have a common
place to give messages to the user, either in a header or footer of
the page.

-When I create a new WebForm, I change the inheritance to be from
MyBasePage instead of System.Web.UI.Page. I place a Label on the
..aspx templace on each new form and call it "Msg". The Msg object,
although placed within the .aspx page, is not declared within the .cs
file since it is declared in the base class. Everything works fine
and compiles.

Now this is where things go wrong::

If I switch from the HTML view to the designer for the .aspx page of
any of my descendant web pages, the IDE automatically adds the Msg
object to the list of declared page variables within the .cs file.
This, in turn, throws a warning during compilation and run-time errors
when the Msg object is accessed in code.

As long as I remove the declaration within the .cs file and recompile,
it all works. However, every time I switch to the page designer, it
replaces the declaration. It appears that the IDE does not verify
inheritance and existance of inherited webform objects before filling
them into the .cs file. Bug? Or am I doing things incorrectly?
Nov 15 '05 #1
0 1023

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by fravelgue | last post: by
14 posts views Thread by Steve Jorgensen | last post: by
1 post views Thread by Benny | last post: by
2 posts views Thread by Dave | last post: by
5 posts views Thread by Bart Schelkens | last post: by
2 posts views Thread by daniel.nebel | last post: by

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.