I have a web page that has several controls with their corresponding event handlers on them. Since 99% of my pages are going to have the same controls and event handlers, I was wondering if it would be possible
to create a base web page that contains these controls/events that all my other pages can inherit from? If it is possible can someone give me an example of how this is done (I have tried a few ideas but they failed to work)?
If you are using ASP.NET2.0, I am afraid you cannot do the inheritance. Because the page class is generated at run time and you never know what is at the design time.
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
mikener
Member
522 Points
235 Posts
Web Page Inheritance
Apr 23, 2007 04:33 PM|LINK
I have a web page that has several controls with their corresponding event handlers on them. Since 99% of my pages are going to have the same controls and event handlers, I was wondering if it would be possible to create a base web page that contains these controls/events that all my other pages can inherit from? If it is possible can someone give me an example of how this is done (I have tried a few ideas but they failed to work)?
Thanks so much.
Girijesh
Contributor
3126 Points
664 Posts
Re: Web Page Inheritance
Apr 23, 2007 04:48 PM|LINK
Use master and content page in asp.net 2.0
http://west-wind.com/weblog/posts/3016.aspx
Put the base controls into the master page.
http://www.girijesh.in/
Jessica Cao...
All-Star
25329 Points
2567 Posts
Re: Web Page Inheritance
Apr 25, 2007 01:55 AM|LINK
Hi mikener,
If you are using ASP.NET2.0, I am afraid you cannot do the inheritance. Because the page class is generated at run time and you never know what is at the design time.
A good choice is using MasterPage, see this tutorial http://quickstarts.asp.net/QuickStartv20/aspnet/doc/masterpages/default.aspx
Hope it helps,
Jessica
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
mikener
Member
522 Points
235 Posts
Re: Web Page Inheritance
Apr 25, 2007 02:29 PM|LINK
Thanks to the both of you. I had not thought of using the MasterPage to accomplish this.