Hi,
I'm currently loading my masterpage from a file via an httpmodule.
How can I modify this code to load the masterpage from a database? Is
the only way to save the file to a temp file first and load via
page.MasterPage File?
Thanks,
Paul.
using System;
using System.Web;
using System.Web.UI;
public class MasterPageModul e : IHttpModule
{
public void Init(HttpApplic ation context)
{
context.PreRequ estHandlerExecu te += new
EventHandler(co ntext_PreReques tHandlerExecute );
}
void context_PreRequ estHandlerExecu te(object sender, EventArgs e)
{
Page page = HttpContext.Cur rent.CurrentHan dler as Page;
if (page != null)
{
page.PreInit += new EventHandler(pa ge_PreInit);
}
}
void page_PreInit(ob ject sender, EventArgs e)
{
Page page = sender as Page;
if (page != null)
{
page.MasterPage File = "~/MasterPage.mast er";
}
}
public void Dispose()
{
}
} 4 2135
yes, you have to write to a temp file, so the the aspnet_compiler can
see it.
-- bruce (sqlwork.com) pa******@hotmai l.com wrote:
Hi,
I'm currently loading my masterpage from a file via an httpmodule.
How can I modify this code to load the masterpage from a database? Is
the only way to save the file to a temp file first and load via
page.MasterPage File?
Thanks,
Paul.
using System;
using System.Web;
using System.Web.UI;
public class MasterPageModul e : IHttpModule
{
public void Init(HttpApplic ation context)
{
context.PreRequ estHandlerExecu te += new
EventHandler(co ntext_PreReques tHandlerExecute );
}
void context_PreRequ estHandlerExecu te(object sender, EventArgs e)
{
Page page = HttpContext.Cur rent.CurrentHan dler as Page;
if (page != null)
{
page.PreInit += new EventHandler(pa ge_PreInit);
}
}
void page_PreInit(ob ject sender, EventArgs e)
{
Page page = sender as Page;
if (page != null)
{
page.MasterPage File = "~/MasterPage.mast er";
}
}
public void Dispose()
{
}
}
<pa******@hotma il.comwrote in message
news:11******** **************@ 79g2000cws.goog legroups.com...
How can I modify this code to load the masterpage from a database? Is
the only way to save the file to a temp file first and load via
page.MasterPage File?
In addition to what Bruce said, a MasterPage by definition is going to get
called probably more than all the other pages in your app combined, so what
you're proposing to do is likely to be extremely inefficient in terms of
performance and resources.
Is there a specific reason you need to do this? MasterPages are very
flexible and quite easily programmable...
It's just a requirement that my app will have a large number of
MasterPages (hundreds of clients, each with their own visual identity).
I understand what was said about performance but it would have been
nice to be given the option of, say, reading from db, storing to cache
and then subsequently loading from cache.
However, temp files are pretty straightforward though so shouldn't be a
problem.
Thanks for all you help,
Paul.
<pa******@hotma il.comwrote in message
news:11******** **************@ 79g2000cws.goog legroups.com...
It's just a requirement that my app will have a large number of
MasterPages (hundreds of clients, each with their own visual identity).
I have exactly the same requirement. Each client has their own MasterPage,
which I set when the site loads.
Go here: http://www.inthecage.co.uk and click the "Log in" button in the top
right-hand corner.
Now go here: http://www.sanctuaryrig.co.uk, enter the site, and click the
"Log in" button in the top right-hand corner.
Of course, it's exactly the same secure site, just with a different
MasterPage. No need for reading from a database, creating a temporary file
etc...
I understand what was said about performance but it would have been
nice to be given the option of, say, reading from db, storing to cache
and then subsequently loading from cache.
Again, there simply is no need whatsoever to do this...
However, temp files are pretty straightforward though so shouldn't be a
problem.
I see. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dawg1998 |
last post by:
I have a page that creates dynamic textboxes based on the number of
fields a user chooses to fill out.
This process worked great when the page was standalone. However, when I
move to a Content/MasterPage setup, the MasterPage Form seems to be
interfering with the ability of my code to retrieve the value in the
dynamic control.
Are there any ideas on why this is happening or how to work-around the
problem? What is the syntax to find a...
|
by: Alex Maghen |
last post by:
I have a master page which contains a general page framework and also
contains a <form runat=server> around most of the content of the page. Inside
that <form> tag is a ContentPlaceholder.
I then create an ASPX which is tied to that MasterPage and in it a put a
bunch of form fields and an <asp:Button />. When I try to run the page, I
get...
"Control 'ctl00_BodyCPH_ctl00' of type 'Button' must be placed inside a form
tag with...
|
by: Cenk Genisol |
last post by:
Hi NG,
I am relatively new to Web developement and have some questions to you.
I've got a Masterpage where some graphics are embedded by CSS. They format
the borders of tables, which store page content so it's just an optical
background.
During the process of loading the page on the client, pages which implement
the above mentioned masterpage are build very excursive. That looks
|
by: =?Utf-8?B?QmVuIFIu?= |
last post by:
Hi,
WHen I specify my master page in the page's @Page directive, no problems.
However, when I put it ias an attribute in Web.config's page element, the
designer fails. It just says "Error Creating Control - Content. Content
controsl can only be used in a content page." I know that there's an issue w/
nested masters, but I'm only trying to use one. Interestingly, if I run the
site, it builds and displays properly despite this error. Any...
|
by: Bon |
last post by:
Dear all
I create a master page with image buttons on the left-hand side for
navigation. When a user clicks the student button, the content (i.e.
ContentPlaceholder) in masterpage will be changed from default.aspx to
students.aspx.
I tried to create a subroutine in MasterPage.master.vb to do it. The
code is as following. But, the default.aspx's content is shown in
MasterPage even I clicked the student button.
| |
by: Randy Smith |
last post by:
Hi,
I now need to add MasterPages to a number of existing forms, but when I add
the code for MasterPage, the MasterPage does NOT appear when it runs.
Any thoughts?
TIA, Randy Smith
|
by: dixonjm |
last post by:
Hi,
I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page.
When I try to load the CSS & JS files using the code behind of the content page, my buttons aren't rendered and Im not sure why?
Here is the code for my content page - Properties.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" Title="Properties"...
|
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= |
last post by:
I have a MasterPage. The MasterPage actually contains the <formtag which is
used throughout the site.
On just certain pages that use that MasterPage, I need the "enctype" for the
<formtag to be set to:
enctype="multipart/form-data"
On the rest of the pages, I do not need this.
How can my specific ASPX page that uses the MasterPage change the
|
by: =?Utf-8?B?SmFwZQ==?= |
last post by:
Can I refer to the controls on default.aspx from the masterpage?
I have a form on the masterpage which sends information that is in a
gridview in the default.aspx page.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |