Access inherited aspx control from base aspx ?

J

Jeff User

Hello
I am using C#, .net1.1
Vis Studio 2003
I am using homeBase.aspx.cs page as a base for several other
aspx/aspx.cs web pages. The base page handles some operations that are
common to all pages. like this:
somepage...
public class homeBase : System.Web.UI.Page
....
then other pages.....
public class WebForm1 : DBMS.homeBase
public class WebForm2 : DBMS.homeBase
etc..

I never actually use the homeBase.aspx page for anything.
I would like to put a label in the same place on all my inherited aspx
pages and set the Text property from the base page code.
Now I am quite sure that the asp code in the base can not be
inherited. I can't just place a label on homeBase.aspx and expect it
to show up in WebForm2, although that would be ideal. So, is there a
way that I can place the label on every inherited form
WebForm1.Label1, WebForm2.Label1, etc..and then access it (Label1)
from the homeBase.aspx.cs code, every time one of these inherited
forms loads?

I tried to create Label1 on the inherited forms and also create one on
homeBase.aspx. page. (just so the code would be generated the same in
all places) . Now the problems begin when I compile.
WebForm1 gets an error at the label declaration stating that it needs
to have the word NEW in front of it "because it hides inherited member
DBMS.homeBase.Label1". To spare the details, (unless required) from
there it is all down hill.

Phew
Any ideas? tryed to be clear without to many words...
Thanks
Jeff
 
B

Bruce Barker

you have two choices

1) delete the label declaration in the inherited page (and thus use the base
declartion). don't use new (as then they are two variables).

2) use Page.Find() in the basepage to access the label

-- bruce (sqlwork.com)
 
J

Jeff User

Fabulous !!
I opted to
1) delete the label declaration in the inherited page (and thus use
the base declartion).
Works like a charm!!

Are there any benefits or pitfalls to doing this one way over the
other?
Thanks
Jeff
 
J

Jeff User

Well, I can see 1 problem already.
Everytime you open the aspx page again and then the solution
re-compiles, it re-creates the declaration.

I will have to look into maybe creating them at run-time.
Yes/no, any thoughts?

Jeff
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top