Setting an ASP.NET Master Page at runtime

前端 未结 6 1206
星月不相逢
星月不相逢 2021-02-04 15:45

I\'m working on a site which needs to be able to support two or more looks, changable at runtime. I\'d hoped to be able to handle the change with a CSS switch, but it looks like

6条回答
  •  忘了有多久
    2021-02-04 16:23

    It's easy enough to handle PreInit and insert the one line of code it takes to load the proper Master Page.

    this.Page.MasterPageFile = "~/default.master";
    

    In the absence of some compelling reason not to go this route, that's what I'd do, regardless of where you handle the PreInit.

提交回复
热议问题