master-pages

can someone confirm my understanding about asp.net live cycle?

隐身守侯 提交于 2019-12-06 10:18:55
问题 my goal is to find a way to update the title of the page at the very last moment before it get created I have a master page and a content place holder that always contain a page with a specific property. that property can be updated anywhere in the code but I want the final value of that tag to be the html title is the prerender event of that page the best place to set the title? 回答1: PreRender is one place where you could set the title, another -later- is PreRenderComplete : protected void

Can content page use ContentPlaceHolderID of master parent of its master page (nested master pages)

醉酒当歌 提交于 2019-12-06 10:07:26
问题 I have a 3 level nested master pages and a content page. parent1 is the top parent, parent2 is parent of parent3 and parent3 is the parent of the content page. I get an error ' Cannot find ContentPlaceHolder xxx... ' where xxx is a ContentPlaceholder. It resides in parent2 and content page is trying to fill it. Can content pages only use their direct parent ContentPlaceHolders or can they also use any of the higher master pages? 回答1: There is one way to do this but there is a slight problem

ASP.NET call a controller method from the master page?

谁说我不能喝 提交于 2019-12-06 08:05:59
In ASP.NET MVC2 how do you call a controller method from the master page? Say for example I wanted to include some overview data in the master: +--------------------------------------+ | Logo Welcome xyz| +--------------------------------------+ | total sales this month $999 | +--------------------------------------+ | Home | Sales | Import | Export (menu)| +--------------------------------------+ And I have inside the Sales controller this method: public ActionResult TotalSalesThisMonth() { var totalSalesModel = SalesService.GetTotalSalesThisMonth() return View(totalSalesModel); } How can I

Problem with Master Page and Virtual Path Provider

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:23:24
I built a deployable master page into a dll and referenced it in multiple ASP.NET Web Applications using a virtual path provider. The problem I'm having is that this really confuses the source view of my aspx pages. Here is the code inside each of my aspx.cs pages which actually attatches the MasterPage to each content page, but as I said, now, my <asp:Content> tags get really confused and I cant CTRL K + CTRL + D my content pages anymore, it throws validation errors on EVERYTHING. HELP! protected override void OnPreInit(EventArgs e) { MasterPageFile = MasterPageVirtualPathProvider

asp.net changing Master Page section css from Content page

泪湿孤枕 提交于 2019-12-06 07:11:44
I have the following code in my master page: <div id="body" runat="server"> <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" /> <section runat="server" id="sectionMainContent" class="content-wrapper main-content clear-fix"> <asp:ContentPlaceHolder runat="server" ID="MainContent" /> </section> </div> For one specific content page I would like to change the class value of the <section> above to something like class="content-wrapper-full-width main-content clear-fix" How can I access the <section> 's attributes from codebehind of the content page and modify its value? Tim Schmelter You

is there a simple way to remove the “ct100” prefix from a .NET user control?

左心房为你撑大大i 提交于 2019-12-06 05:50:22
问题 Long story short, dozens of pages use no master page. For a new module I created a master page with a menu control (menu control exists already) so I can get the same look across the six or so pages I'm creating now. Since the content page uses the master page, the Menu control has its name changed to ct100_Menu1 instead of just Menu1 . Wouldn't be an issue except someone decided to use the exact name of the control for the CSS that styles the menu, by its exact ID (e.g. CSS is Menu1 a { /*

HTML inherit page layout

淺唱寂寞╮ 提交于 2019-12-06 05:29:03
问题 Is it possible to have a regular html page inherit its layout from another html page? If so, what is the most advisable approach for doing this? I know that aspx uses .master pages to hold the elements common to all pages in the site. 回答1: You could fetch resources using JS and AJAX if you absolutely cannot use a serverside language. how can we avoid header and footer code repeating in each html pages Jekyll works too: What is the best way to manage duplicate code in static HTML websites 回答2:

How To: add dynamically HiddenField in masterpage base page

最后都变了- 提交于 2019-12-06 04:44:07
I have a Base MasterPage class, from which my masterpages will inherit. I have some javascript functions there for it's child pages to include. As it's a base class, it does not have a visual designer nor I can add XHTML code. I need to add a hidden field to the class so I can set it's value in the javascript code, and when a postback occurs I can get the setted value on my content pages. Yet I fail to achieve this, for when I try to add the hidden field to the base masterpage's control collection I get a render error (Content Encoding error if viewed in Firefox). And If I try cheating and

How do I reference a master page from an aspx page?

喜你入骨 提交于 2019-12-06 04:32:13
How do I reference a master page from an ASP.NET webform? The following statement does not work: this.MasterPage.Page.Title = "My Title"; In your aspx, below the Page directive, write: <%@ MasterType VirtualPath="YourMasterFile" %> And then from your code, write Master. anything that you want to use, for example: Master.Title = "My Title"; you have to cast this.MasterPage into the type of masterpage you have, and then you can access it as you'd expect var mp = this.MasterPage as MyMasterPageType; mp.Property = value... etc From the Page you can use the Master property and cast this to your

How to provide ASP.NET MVC2 master pages with a model indepdent of the controller

瘦欲@ 提交于 2019-12-06 04:11:49
I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I can't find a way to easily inject the master or a partial view included in the master via either ctor or property injection. I can't imagine this is an uncommon task, but all I can find in terms of methods is Controller subclassing to stuff data into untyped