How do i: Visual Inheritance

J

John Blair

Hi,

I have one form that i want to make similar to another form but add some
additional controls. I thought the following code would make my webform4
have all the content of webform3 but nothing shows up in webform4.....how do
i make this work?

Thanks.
Public Class WebForm4

Inherits WebForm3
 
E

Eliyahu Goldin

In asp.net 2.0 you have Master pages. There are some 3rd party
implementaions for 1.1. Google for something like "Master Pages for ASP.NET
1.1"

Eliyahu
 
P

Philip Q [MVP]

This is not possible, because, although all of your controls are instance
variables in the WebForm3 class, there is no rendering code in WebForm3.
If you embed the rendering code inside of WebForm3 (probably inside of
InitialiseComponent), by adding the controls to Page, the controls and their
rendering will also be inherited.
 
J

John Blair

Thanks a lot for the feedback....i dont understand the rendering process - i
thought webform3 contained its own redering by default as the controls
display for webform3 when it is say the default start page....but i take
your word this is not possible! Thanks.

Philip Q said:
This is not possible, because, although all of your controls are instance
variables in the WebForm3 class, there is no rendering code in WebForm3.
If you embed the rendering code inside of WebForm3 (probably inside of
InitialiseComponent), by adding the controls to Page, the controls and
their rendering will also be inherited.

--
Philip Q
Microsoft MVP [ASP.NET]

John Blair said:
Hi,

I have one form that i want to make similar to another form but add some
additional controls. I thought the following code would make my webform4
have all the content of webform3 but nothing shows up in webform4.....how
do i make this work?

Thanks.
Public Class WebForm4

Inherits WebForm3
 
J

John Blair

Hi,

Thought about what you wrote and tried my example with windows forms - it
works for that!
I now see that with web forms my webform3 is the code behind class only and
not the "HTML" part which i presume does the
rendering so hence no display of controls when i just inherit the code
behind class!
Was nice to see this work with windows forms though! Thanks again!

John Blair said:
Thanks a lot for the feedback....i dont understand the rendering process -
i thought webform3 contained its own redering by default as the controls
display for webform3 when it is say the default start page....but i take
your word this is not possible! Thanks.

Philip Q said:
This is not possible, because, although all of your controls are instance
variables in the WebForm3 class, there is no rendering code in WebForm3.
If you embed the rendering code inside of WebForm3 (probably inside of
InitialiseComponent), by adding the controls to Page, the controls and
their rendering will also be inherited.

--
Philip Q
Microsoft MVP [ASP.NET]

John Blair said:
Hi,

I have one form that i want to make similar to another form but add some
additional controls. I thought the following code would make my webform4
have all the content of webform3 but nothing shows up in
webform4.....how do i make this work?

Thanks.
Public Class WebForm4

Inherits WebForm3
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top