locked
In EW4 can I dynamically swap master pages at runtime? RRS feed

  • Question

  • I seem to have outsmarted myself so if this post seems a bit long winded I apologize in advance.

    I have been tasked with converting an old asp web site to asp.net and have been working on it for about 10 weeks.  I'm used to using Visual Studio 2008 and don't have much experience with Expression Web 4.  I'll skip over the whole ordeal of making the navigation easy to maintain and upgrading all of the css and html to current standards.  The bottom line is that I am used to using master pages to control appearance and some of our pages may have multiple master pages that are selected from at run time.

    In Visual Studio I just add the PreInit event and put a select case in to tell the server which master page to use based on a QueryString parameter.  If I publish the site via VS2008 and the site editor goes in via EW4 and adds a page, how can they set up the page to dynamically change master pages?  Does EW4 have PreInit events?  Since VS2008 creates a dll, will EW4 be able to rebuild the dll? 

    I've done multiple web searches and I don't find anywhere that this is addressed.

    Thanks for any help at all.

    Wednesday, February 23, 2011 2:59 PM

Answers

  • Neither VS nor EW have preinit events.

    Asp.net has them, and you write what you want to do during them, in either program.

    There is a difference between them in how much hand-holding you have for writing what you want to do during an event, because VS knows more about asp.net than EW does and will, for example, automatically set up a code-behind page for you, if you have that option checked, when you create a page. EW doesn't do that, and you either use the one-page coding model in EW, or create your own code behind pages from scratch.

    If you need to create a new dll, rather than let the pages compile on the server or reference an already existing dll, you'd need to go back to VS. EW doesn't do builds.

    • Marked as answer by twellsles Wednesday, February 23, 2011 3:44 PM
    Wednesday, February 23, 2011 3:08 PM
  • Since I don't know what is in the code behind pages, I can't answer you.

     What you need to know is if stuff that's being changed is precompiled and sent up in dlls. If it is, working on the server won't work.  You'd need to rebuild the project after the changes.

    If the site doesn't use precompiled dlls, or if the only changes you make in the pages don't require a change in the dlls, then it doesn't matter where the changes are made.

    Asp.net will compile on the fly what you don't precompile in dlls. (You can have an entire site without you creating a single dll, if you want to. Control and efficiency will determine your path.)

    And: I think you need to be looking at the asp.net forum, since this is well beyond an EW topic. http://forums.asp.net/ 

    • Marked as answer by twellsles Wednesday, February 23, 2011 3:44 PM
    Wednesday, February 23, 2011 3:34 PM

All replies

  • Neither VS nor EW have preinit events.

    Asp.net has them, and you write what you want to do during them, in either program.

    There is a difference between them in how much hand-holding you have for writing what you want to do during an event, because VS knows more about asp.net than EW does and will, for example, automatically set up a code-behind page for you, if you have that option checked, when you create a page. EW doesn't do that, and you either use the one-page coding model in EW, or create your own code behind pages from scratch.

    If you need to create a new dll, rather than let the pages compile on the server or reference an already existing dll, you'd need to go back to VS. EW doesn't do builds.

    • Marked as answer by twellsles Wednesday, February 23, 2011 3:44 PM
    Wednesday, February 23, 2011 3:08 PM
  • Thanks for the VERY fast answer!  So if my site editor goes in and adds a page via EW4, can she also just paste in some inline code creating a PreInit event for the page?  Since the site has been built in VS it has a dll with all of the activity  in it.  I'm assuming that the newly added page from EW4 won't actually be included in the dll.

    Perhaps I should expand a little.  I'm working on my local machine and then publishing to the server.  The editor will be working directly on the server.  I've found that if I publish the code behind pages and then the editor goes in and alters the code behind page, the change isn't reflected at run-time.  Should I be working directly on the server as well?

    • Marked as answer by twellsles Wednesday, February 23, 2011 3:43 PM
    • Unmarked as answer by twellsles Wednesday, February 23, 2011 3:44 PM
    Wednesday, February 23, 2011 3:21 PM
  • Since I don't know what is in the code behind pages, I can't answer you.

     What you need to know is if stuff that's being changed is precompiled and sent up in dlls. If it is, working on the server won't work.  You'd need to rebuild the project after the changes.

    If the site doesn't use precompiled dlls, or if the only changes you make in the pages don't require a change in the dlls, then it doesn't matter where the changes are made.

    Asp.net will compile on the fly what you don't precompile in dlls. (You can have an entire site without you creating a single dll, if you want to. Control and efficiency will determine your path.)

    And: I think you need to be looking at the asp.net forum, since this is well beyond an EW topic. http://forums.asp.net/ 

    • Marked as answer by twellsles Wednesday, February 23, 2011 3:44 PM
    Wednesday, February 23, 2011 3:34 PM
  • And: I think you need to be looking at the asp.net forum, since this is well beyond an EW topic. http://forums.asp.net/  

    I posted there first and never got an answer.  You seem to know more about it than the VS/ASP.Net experts.  Thanks again!  I'm a lot closer to a working solution than I was an hour ago.  I'm marking this thread as answered because you addressed the main issue I needed to know about.
    Wednesday, February 23, 2011 3:43 PM
  • If anyone wants to know how I ended up handling this go to the ASP.Net forums to my thread there:

    http://forums.asp.net/p/1656243/4316503.aspx/1?p=True&t=634340597740338727
    Wednesday, February 23, 2011 5:12 PM
  • Well, one note on your posted link: You could do all the editing in EW if you wanted to. As I said, neither EW nor VS "fire off" preinit events, that happens on the server.

    VS will help you write the code, while you need to know what to do manually in EW. That's the difference as far as that goes.

    But, as I also said, EW also won't build (create dlls) if you are using those. If you need to rebuild dlls, yes, you need to use VS, and from the work flow you described (which included rebuilding the site), yes, in your case that applies.

    Wednesday, February 23, 2011 5:19 PM
  • Yeah -- the girl rocks!



    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with FP, Access, Bots and Wizards
    LawOfAllTheLand.org -- Created with Expression, VWDExress, SQL Express, and ASP.NET.
    Arvixe -- My favored web host
    Thursday, February 24, 2011 12:16 AM