master-pages

Can I change a nested master page's master dynamically?

你说的曾经没有我的故事 提交于 2019-12-17 19:28:16
问题 Okay, so we all know about changing a master page dynamically in a page's OnPreInit event. But what about a nested master page? Can I change a master's master? There is no OnPreInit event exposed in the MasterPage class. Any ideas? 回答1: Just tested this and it works from the PreInit of the Page that is using the nested MasterPage. protected void Page_PreInit(object sender, EventArgs e) { this.Master.MasterPageFile = "/Site2.Master"; } Obviously you will need to ensure that the

Finding controls inside nested master pages

血红的双手。 提交于 2019-12-17 16:29:09
问题 I have a master page which is nested 2 levels. It has a master page, and that master page has a master page. When I stick controls in a ContentPlaceHolder with the name "bcr" - I have to find the controls like so: Label lblName =(Label)Master.Master.FindControl("bcr").FindControl("bcr").FindControl("Conditional1").FindControl("ctl03").FindControl("lblName"); Am I totally lost? Or is this how it needs to be done? I am about to work with a MultiView, which is inside of a conditional content

Hook a javascript event to page load

流过昼夜 提交于 2019-12-17 16:12:29
问题 I have an aspx that has the following javascript function being ran during the onload event of the body. <body onload="startClock();"> However, I'm setting the aspx up to use a master page, so the body tag doesn't exist in the aspx anymore. How do I go about registering the startClock function to run when the page is hit and still have it use a masterpage? 回答1: If you don't want to explicitly assign window.onload or use a framework, consider: <script type="text/javascript"> function

How to use JQuery with Master Pages?

一个人想着一个人 提交于 2019-12-17 15:29:25
问题 I can get simple examples to work fine as long as there's no master page involved. All I want to do is click a button and have it say "hello world" with the javascript in a .js file, using a master page. Any help very much appreciated :) 回答1: EDIT As @Adam points out in the comments, there is a native jQuery mechanism that basically does the same thing as the hack in my original answer. Using jQuery you can do $('[id$=myButton]').click(function(){ alert('button clicked'); }); My hack was

Is it possible to share a masterpage between MVC and webforms?

99封情书 提交于 2019-12-17 15:25:16
问题 I am adding MVC to a project that has MANY legacy webform pages. This works fine. However, I currently have a separate masterpage for MVC and for the webforms. The two master pages produce essentially identical output. I'd really like to kill the webforms one and just use the MVC master page with all my pages and stay DRY. Not being DRY has already bitten me a couple times when I forgot to change both. I tried doing the obvious way and just pointing the webform content page's MasterPage

how to access master page control from content page

断了今生、忘了曾经 提交于 2019-12-17 05:01:02
问题 I have a master page which contains a label for status messages. I need to set the status text from different .aspx pages. How can this be done from the content page? public partial class Site : System.Web.UI.MasterPage { public string StatusNachricht { get { return lblStatus.Text; } set { lblStatus.Text = value; } } protected void Page_Load(object sender, EventArgs e) { } } I have tried this, but was unsuccessful in making it work: public partial class DatenAendern : System.Web.UI.Page { var

Where does error CS0433 “Type 'X' already exists in both A.dll and B.dll ” come from?

给你一囗甜甜゛ 提交于 2019-12-17 03:01:53
问题 When I run a webapp from Visual Studio 2008 SP1 using the internal web server (not IIS) I receive the above mentioned error. The full error (source file Default.aspx.cs ): Compiler Error Message: CS0433: The type 'WebApplication3.Site1' exists in both 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_site1.master.cdcab7d2.muczzy9v.dll' and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\assembly

including jquery menu and jqGrid on the page

点点圈 提交于 2019-12-14 03:49:43
问题 I have a navigation menu which I need to include on all my pages....through jsp I just include the that menu <div id="header"><jsp:include page="../menu_v1.jsp"/></div> but problem is that my menu contains <html><head></head><body></body></html> Now when I want to use my jqGrid which is define on my new page inside <script></script> it doesn't show up....because its conflicting with my header jquery script...My tried solutions: Using iframe but this will not let me control my other pages.

This page is missing a HtmlHead control which is required for the CSS stylesheetlink that is being added. Please add <head runat=“server” />

喜夏-厌秋 提交于 2019-12-14 03:33:23
问题 This page is missing a HtmlHead control which is required for the CSS stylesheetlink that is being added. Please add <head runat="server" /> . i have given runat="server" but issue does not resolve what is issue how it will be resolved. i get this error after providinf runat=server Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception

how to disable controls of master page used in content page while processing some event in asp.net

心已入冬 提交于 2019-12-13 23:18:04
问题 The following code works fine for disabling content page controls, but how do I disable master page controls? public void DisableControls(Control control,bool isEnable) { if (control.HasControls()) { foreach (Control c in control.Controls) { DisableControls(c, isEnable); } } else { if (control is IPostBackDataHandler && !(control is IPostBackEventHandler)) { if (control is WebControl) { ((WebControl)control).Enabled = isEnable; } else if (control is HtmlControl) { ((HtmlControl)control)