master-pages

Why is Context.User null on ASP.NET Master Page now?

I just swiched to a new ASP.NET host and it seems it is behaving differently. In the code for the master page it is attempting too do some different logic for authenticated users by this. if (Context.User.IsAuthenticated) { } But the Context.User object is null. But it's only null on the master page. If I use it on the regular page it...

Masterpage with Silverlight (C#) and Legacy ASP.NET (VB.NET) code

I'm working to include Silverlight functionality in a legacy web application based in VB.NET. With the change we are also switching from VB to C# (all new development is C#, so I need a C# answer). I'd like to use some form of master page where the content area can house either a silverlight control or a legacy module/page. The options...

jQuery calls in external js file with MasterPages

I am using ASP.NET 3.5 with MasterPages. My master page has the script references to jquery and jquery UI. My web page that uses the master page has a script reference for a custom javascript file for that page. This javascript file has jquery calls in it (i.e. document.ready --> set up input boxes as calendars). When I run the websi...

Masterpage -> SubMasterPage -> Web Form...getting properties of Masterpage in sub pages

I asked a related question on this yesterday, and was told what not to do, but not what I should do. I've got a master page that I'll call "TheMaster". I've got 2 sub master pages "Sub1" and "Sub2". They both have a Masterpage directive of "TheMaster". Web Forms have a Masterpage directive of "Sub1" or "Sub2". These aren't the real ...

asp.net change masterpage / hide show details dependent on theme

Is it possible to dynamically change the masterpage on the whole project dependent on current active theme ? or alternatively i need to hide / show details on my existing masterpage dependant on the active theme, hope that makes sense. suggestions please Thanks ...

Disable control in .aspx from Masterpage conditionally

Ok, this might be a bit weird, so I'll start with explaining what I'm trying to do. I have several masterpages for my site, and in they inherit each other. In the second of them (4 in total) I have a background image. Here comes the trick, I'd like to override this image from the final aspx page. I can't change the position of this image...

MasterPage/ContentPage with NVelocity and ASP.NET MVC?

I am a big fan of NVelocity. I think its terse syntax is a huge boon, and helps keep my views simple and effective. I have begun using the NVelocity view engine from the Mvc Contrib project for ASP.NET MVC, along with the Castle NVelocity .vm syntax highlighter. While I love what NVelocity brings to the table, I am really missing one f...

Disable Session from Master Page

In ASP.NET, I would like to disable session state from master page, however @Master directive doesn't have EnableSessionState attribute as @Page does. Is there any workaround? ...

Master Pages.. and applying a css classes to the body element

I have a master page which a generic a menu that looks like this: <div id="menu"> <ul class="sf-menu"> <li class="menuHome"><a href="/home">Home</a></li> <li class="menuBandsAZ"><a href="/artist/list">Bands</a></li> <li class="menuGigs"><a href="/gig/list">Gigs</a></li> </ul> </div> <asp:ContentPlaceHolder ID="ListingPlaceHolder"...

How can I tell whether an asp:ContentPlaceHolder has been populated in MVC?

I have a master page with a content control. I want it to do something specific during load if a particular content place holder has been used. APageWithContent.aspx <asp:Content ContentPlaceHolderID="myContent" runat="server"> <div>hello world!</div> </asp:Content> MasterPage.aspx <asp:ContentPlaceHolder ID="myContent" runat="s...

Issue with asp:ContentPlaceHolder and code blocks

When a content placeholder contains any code blocks it reports that the control collection is empty. For instance: MasterPage.aspx <asp:ContentPlaceHolder ID="Content1" runat="server" /> <asp:ContentPlaceHolder ID="Content2" runat="server" /> <div>Content1: <%= Content1.Controls.Count %></div> <div>Content2: <%= Content2.Controls.Cou...

Master pages -- Getting calling page name

Can someone tell me how to get the name of the child page being called in a Master page scenario. For example, if I have the following masterpage: <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-trans...

ASP.NET MVC - Set ViewData for masterpage in base controller

I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData to be present, which displays this on every page. If I don't set this ViewData key in my controllers, I get an error that it can't find it. However, I don't want to set the ViewData in every controller (I don't want to say ViewData["foo"] = GetFoo();...

does anyone have a vb.net function that will iterate through master page control hierachy?

Does anyone have a function that will iterate through ever masterpage/sub masterpage that a content form belongs to, and iterate through each control of said masterpage/sub masterpage? The reason why i ask is that i'm building up an increasingly confusing stack of masterpages and am starting to "lose" controls - i.e. not being able to f...

Temporarily override Theme CSS in ASP.NET

I have a MasterPage that is two column layout, left column menu, right column content. The whole page is XHTML/Divs/CSS layout. So the columns are div's with CSS applied to size them. For one page, a grid page, I want only one column (the content column) to be 100% width for maximum viewing area. How can I use the same masterpage and ...

What item should I create in ASP.NET MVC if I want to break a view into smaller sub-views?

I have an ASP.NET MVC application I'm building and I'm using a Master page. On this master page, I would like to further break things up by creating a separate file for "Tabs", "Header", and "Footer". What kind of view should I create to encapsulate these things to help remove clutter from my Master Page? Also, how do I reference th...

How to get the URL of the page that called a function?

Here is a code sample: myMaster.Master <asp:LinkButton runat="server" OnClick="anAction_Click"> calls: myMaster.Master.cs protected void anAction_Click(object sender, EventArgs e) { ??? Request.getUrlOfThePageCalling? ??? } I'm using a master page. How do I get the page that cal...

How to persist scroll position using Master Page?

Hi, I have a site that uses master pages, the only content that changes is a Div in the centre of the page. Is there a way that I can persist the scroll position of the page between postbacks? I'm thinking that it might be possible because all pages are using the same Master Page, if not is there some other way to do this? Thanks ...

Where should I include a javascript reference for a view that inerhits from a Master view in ASP.NET MVC?

I have a bunch of pages inheriting from a master view. One one of these pages I want to use a popular jQuery plugin called "Uploadify". Where should I place the reference for the Uploadify javascript file? I only need it on one small page so it didn't seem right to place it in Master view. Is it 'Ok' to place it in the content tag ...

Import Master Page into another Master Page in ASP.NET

Is it possible to make one master page simply include another master page? I have three master pages, which have converged in content, and I want to make 2 of them point to the third, so that the content is not replicated, but leaving them in so that they can change easily in the future if they have to. ...