CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/21/2006 7:01:54 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 169 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
krul
Asp.Net User
Error trying to dynamicaly change the master page behind the webform4/21/2006 7:01:54 PM

0

While trying to dynamicaly load master page:
        RCFontSize fontSize = GetFontSize();
        switch (fontSize)
        {
            case RCFontSize.Large:
                Page.Master.MasterPageFile = "~/MasterPages/Admin/MainLayout_T_Large.master";
                break;
            case RCFontSize.Medium:
                Page.Master.MasterPageFile = "~/MasterPages/Admin/MainLayout_T_Medium.master";
                break;
            case RCFontSize.Small:
                Page.Master.MasterPageFile = "~/MasterPages/Admin/MainLayout_T_Small.master";
                break;
            default:
                Page.Master.MasterPageFile = "~/MasterPages/Admin/MainLayout_T_Medium.master";
                break;


I have experienced following error:

MasterPage cannot be applied to this page because the control collection is read-only.
 If the page contains code blocks, make sure they are placed inside content controls (i.e. <asp:Content runat=server />)

The page loading is an empty page which just assign src property of the frames on master pages which is inhereted from class to expose frame src propetry.

I hope I was clear enough,
Any help is greatly appreciated.

P.S. There is no code blocks on loading page. just two events on codebehind page preinit and pageload which contain the code.
ScottGu
Asp.Net User
Re: Error trying to dynamicaly change the master page behind the webform4/22/2006 5:02:24 AM

0

Hi Krul,

To set a master page dynamically, you need to make sure that the code runs in the Page_PreInit event.  Does the above code run in the Page_Load or Page_PreInit method?

Thanks,

Scott

krul
Asp.Net User
Re: Error trying to dynamicaly change the master page behind the webform4/22/2006 2:42:50 PM

0

Hi Schot
Thanks for fast respond.
Yes code is placed in PreInit event of the page. Meanwhile I have found the problem.
1. Page.Master.MasterPageFile (this was fixed into Page.MasterPageFile stupid me)
2. On master page mark up  i have changed <head> into <head runat=server>
It is working now.
Thanks again

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Passing master page form data to another webform - Stack Overflow When i add multiple forms i get the error that i only can have one form. With Server. ... Add some code to the master page code-behind to detect the source of the POST. .... Can I change a nested master page's master dynamically? ...
How to Use Master Pages in Visual Studio and C# Add a New Item to website; Web Form. Check Select master page, and choose the ... To change the Master Page dynamically.. Create a new Master Page different ...
vbCity/DevCity.NET Forums :: FAQ :: .NET :: ASP.NET :: Web Development Web Development (6). faq, Error Handling (1), faq .... So how do you change the master page on a web site dynamically? .... I decided to use code-behind pages when I defined the master page (this isn't important .... And you can even hold onto some "hidden" data on the web form which the user can't ...
Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web ... This walkthrough assumes you are using code-behind files for all pages. If you are using a single-file ASP. .... Under Visual Studio installed templates, click Web Form. ..... This allows you to dynamically change the look of the master page at run time. ... I followed the sample and got the following error; ...
Beginning ASP.NET 2.0 Accessing Code in Master Pages. Just as a standard Web Form object is inherited from System. ... then open up the code-behind file of each Master Page and change the class .... Message: FYI, this causes an error due to the closing tags : ... the user control dynamically other than finding control and loading them. ...

Error trying to dynamicaly change the master page behind the ... Error trying to dynamicaly change the master page behind the webform, > ROOT > NEWSGROUP > Asp.Net Forum ...
Error Creating New Web Form - ng.asp-net-forum ... Error trying to dynamicaly change the master page behind the webform ... Create a new Master Page different ... Web Forms Still weird though ...
error: Content controls are allowed only in content page that ... This is the source code of the page that throws the error. ... Error trying to dynamicaly change the master page behind the . ... my masterpage, ... page's code behind that i am trying to reference from my web form. ...
MasterType VirtualPath vs. TypeName - ng.asp-net-forum ... Error 1 'ASP.masterpages_masterpage_master' does not contain a definition ... Error trying to dynamicaly change the master page behind the . ...
update label in masterpage from another page - ng.asp-net-forum ... How to Update or Change the Master Page Variables from a different . ... Asp.Net Forum ... css positioning of dynamically generated labels? wrapper? ...






templates vs themes and skins?

custom sqlsitemapprovider - menu sometimes not rendering at all

sub domain master page help

browser-specific master pages issue

background-image not displaying in table cell

extending pure css layout for menus beyond 2nd level

how can i create new object of page when it requested with different parameters?

problem with masterpage

can't have all three? menu with background image + text with mouseover effect + dropdown submenu??

wizard control onfinishbuttonclick

custom attribute in sitemap

masterpage error: make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. page or usercontrol).

2 questions on web.sitemap

invalid cast to masterpage type

master page properties and nested masters

standard menu control + staticitemtemplate = click disabled...

treeview in master page

dynamic popout menu render beneath contentplaceholder

menu

unable to reach the menuitemclick event handler

dynamic menu item direction...

multiple content

replace navigation sub-menu on the fly

how do i use findcontrol to locate a usercontrol located in a masterpage?

how to bind javascript code to a treeview node ?

some problems with master pages

how to show html pages inside a content placeholder

page does not fully load masterpage when doing url rewriting

menu control with javascript disabled

selecting a selected treeview-node ?

   
  Privacy | Contact Us
All Times Are GMT