How to have multiple page execute same event code?

  • Thread starter Thread starter ryanmhuc
  • Start date Start date
R

ryanmhuc

I'm new to .NET and I'm still trying to adapt from PHP. Especially when
dealing with includes. I would like a group of pages to all execute the
same Page_Preinit event code. In php I would just include a file but I
can't figure out how to accomplish this is .NET

What I'm trying to do is setup a group of pages that depending on which
subdomain will programmatically use a different masterpage. I'm
assuming I have to set the MasterPageFile in the Page_Preinit event but
I don't want to duplicate the code in each page. I'm I going about this
correctly?

Thanks
 
I'm new to .NET and I'm still trying to adapt from PHP. Especially when
dealing with includes. I would like a group of pages to all execute the
same Page_Preinit event code. In php I would just include a file but I
can't figure out how to accomplish this is .NET

What I'm trying to do is setup a group of pages that depending on which
subdomain will programmatically use a different masterpage. I'm
assuming I have to set the MasterPageFile in the Page_Preinit event but
I don't want to duplicate the code in each page. I'm I going about this
correctly?

Thanks

Create a base page class, put the event code in there, and have all pages
inherit from this class.
 

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

Back
Top