master-pages

ASP.NET: How to (programmatically) attach a <script> tag, containing a link to .js, to <head>?

こ雲淡風輕ζ 提交于 2019-12-13 02:32:05
问题 This is the scenario: I'm working on a new ASP.NET application that uses master pages for virtually all of the web pages in it, a few of them nested to 4 levels. Due to the size of the project, I was forced to organize the web pages into folders, at various depth levels. The global, Master (in uppercase) page, located at the root directory, contains some useful Javascript functions that are used all along the web app, and I wanted to place these functions together in a single .js file, in

Why is my session variable declared in master page blank on a web page?

大憨熊 提交于 2019-12-12 21:26:24
问题 I declared in master page load: Session["sessionString"] = "stringX"; in my web page on load also, i call it string sessionString= (string)Session["sessionString"]; i debug and value in web page is "" what is wrong? 回答1: JW Lim is correct...content page's load event will fire before Master page load. @user3445314 , you can use "Session_Start" event in Global.asax and set values same as you set in master page. "Session_Start" event fires first and then your content page load event occur. I

ASP.net MasterPage.master does not exist

泄露秘密 提交于 2019-12-12 20:35:18
问题 I am having a problem while publishing my website on the IIS server, i don't have direct access to it so i have to rely on some one else to configure my website on the IIS. however when i upload my website this error comes up: Line 1: <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %> Line 2: <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> Parser Error

How To retrieve a control in a Master Page from Content Page

一个人想着一个人 提交于 2019-12-12 19:15:03
问题 When I asked recently a question about how To retrieve a control in a Master Page from Content Page . Many peoples suggest me to use this code from my Content Page: Label lbl = this.Master.Page.FindControl("uxLabel") as Label; //Note any server controls defined in the master page could be not be accessible even after a cast is performed, because they could be marked as protected This approach certainly works, I also realize that is available a strongly-typed solution that doesn't involve

how can we avoid header and footer code repeating in each html pages

扶醉桌前 提交于 2019-12-12 18:38:04
问题 I have some ten html pages each page also has same header and footer tag can i have one page with complete header and footer ,and i will refer to that particular page from other html pages. 回答1: You do this by using a server side language like PHP or another one of the myriad different languages out there, which pre-processes the page. Something along these lines: <?php include 'header.html'; ?> ... page contents... <?php include 'footer.html'; ?> 回答2: If you don't care about users who have

SharePoint masterpage css styles not showing for other users

孤街醉人 提交于 2019-12-12 18:26:47
问题 I'm setting up a SharePoint Site where the masterpage is built using one of the existing masterpages as a starting point (Blue Band). When I test the site while logged in as the super admin, everything looks fine. But if I log in as a general user the default masterpage shows as Blue Band again. I'm guessing there must be some permissions problem where the new CSS isn't allowed to show. It appears to just be the CSS as the placement of elements is as per the new master page. 回答1: This usually

How to find label control from content page which is inside master page of user control?

懵懂的女人 提交于 2019-12-12 17:30:50
问题 I have one page: Abc.aspx On this Abc.aspx page i have used one master page that is Master1.Master . Now on this master page i have rendered 1 usercontrol name as Usercontrol1.ascx. On this User control i have put 1 label named as lbl1. <asp:Label runat="server" ID="lbl1"></asp:Label> So now on page load event of Abc.aspx page i want to find this control and i have tried but getting null: protected void Page_Load(object sender, EventArgs e) { var lbl = ((Label)this.Master.FindControl("lbl1"))

ASP.NET MVC displaying user name from a Profile

妖精的绣舞 提交于 2019-12-12 08:57:14
问题 The following is the LogOn user control from a standard default ASP.NET MVC project created by Visual Studio ( LogOnUserControl.ascx ): <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Request.IsAuthenticated) { %> Welcome <b><%: Page.User.Identity.Name %></b>! [ <%: Html.ActionLink("Log Off", "LogOff", "Account") %> ] <% } else { %> [ <%: Html.ActionLink("Log On", "LogOn", "Account")%> ] <% } %> which is inserted into a master page: <div id="logindisplay"> <%

How to use a method in a Master Page from a Content Page

独自空忆成欢 提交于 2019-12-12 08:37:05
问题 I am writing an ASP.NET 4 application with C#. I have a Master Page, inside of which I have the following method: public void DisplayMessage(string input) { Label myMessageDisplayer = (Label)FindControl("uxMessageDisplayer"); myMessageDisplayer.Text = input; } Can I call this method from a content page? At the moment, I use in Content Page this code: Master.DisplayMessage("Item has been inserted."); And I receive this error: 'System.Web.UI.MasterPage' does not contain a definition for

Access an HTML control on ASP Master Page from the code behind of a Content Page

做~自己de王妃 提交于 2019-12-12 07:24:04
问题 I have an ASP.NET / C# application in which the Master Page contain the main menu of my application and several content pages that depend of this master page. I would like to highlight the menu link of my master page corresponding to the current content page displayed. To do that, I already have a CSS class dedicated to this (called "selected") Thus, I was trying to access the Master Page link I want to highlight from the content page by using its ID and do something like that (in the content