master-pages

How to Set Master Page dynamically?

耗尽温柔 提交于 2019-11-30 01:28:41
问题 I have requirement in which i want to set different Master Pages for the Same Page depending upon userid(i.e. for one user it must set one master page and for another user it must set another master ).Can we set different Master pages for any page dynamically?Please help... 回答1: void Page_PreInit(Object sender, EventArgs e) { this.MasterPageFile = "~/MyMaster.master"; } Explanation: You can attach a master page dynamically to a content page. Because the master page and content page are merged

How to use dynamic master page in ASP.NET MVC RC 1.0

北城余情 提交于 2019-11-29 23:50:29
问题 I don't know how to using dynamic master page in ASP.NET MVC RC 1.0. Please help! 回答1: You can specify the name of the master page when using the View() helper method: return View("About", "AlternateMaster", model); AlternateMaster would resolve to ~/Views/Shared/AlternateMaster.master Found this here 回答2: I got this to work by creating a base controller that handled the OnActionExecuted event. In the OnActionExecutedevent I assign the master page. Then I made all my other controllers inherit

ASP.NET: Call function in MasterPage through UserControl

旧城冷巷雨未停 提交于 2019-11-29 20:13:12
问题 Calling a function from the MasterPage in a Page is quite straigt forward but how do I call it for a UserControl: Adding <%@ MasterType VirtualPath="~/MasterPage.master" %> , doesn't work on UserControls. So this.Page.Master.MyFunction() fails :( 回答1: Niels, Leverage reflection (as suggested by JDunkerley) is one approach to the problem. Another you might consider is implementing an interface: Create an interface that includes your method. Implement the interface in your master page From your

Using FindControl to get GridView in a Content Page

被刻印的时光 ゝ 提交于 2019-11-29 16:27:44
I would like to find a GridView Control within a separate class and I am having issues doing so. I even tried placing my code in the aspx.cs page to no avail. I keep getting Object reference not set to an instance of an object. I'm sure there is a simple step I'm missing, but in my research I cannot seem to find anything. Aspx code <asp:GridView ID="GridView1" EnableViewState="true" runat="server" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="933px" onrowdatabound="GridView1_RowDataBound" onrowdeleting="GridView1_RowDeleting" onrowediting=

How do I get ‘footer’ content on a master page to push down when main content doesn't fill a page

假如想象 提交于 2019-11-29 14:50:59
I have the following code for my masterpage: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server" style="position:relative"> <title>Masterpage</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="main" runat="server" style="position:relative"> <div> <asp

Set Property Value on Master Page from Content Page

大城市里の小女人 提交于 2019-11-29 14:11:19
问题 I need to pass data to a variable in my master page each time a page is loaded. I have a string[] of RequiredRoles that I set on each content page defining what roles are required to access that page. On my master page, I have a method that takes this array, and checks to see if the current user is in one or more of those roles. How would I go about managing this? I basically want each page to have a String[] RequiredRoles defined, and the master page will load this on each call and check to

Calling Content Page Method from MasterPage Method [duplicate]

拜拜、爱过 提交于 2019-11-29 13:06:16
Possible Duplicate: content page class method calling from master page class I need to access Content Page Method from Master page Event. How can I do this? Content Page: public partial class Call_Center_Main : System.Web.UI.Page { Page_Load(object sender, EventArgs e) { } public void MenuClick(string ClkMenu) { // Some Code } } MasterPage: public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { //How Can I call MenuClick method from Content Page from Here ??? } }

jquery mobile needs a refresh to work properly

落爺英雄遲暮 提交于 2019-11-29 12:56:28
I wrote two pages using master page in .net and JQM. But when I redirect to second page, JQM swipe control does not works without a refresh. Besides, any control or function like a simple alert() does not work. I am sharing my code: Master Page: <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="UserMaster.master.cs" Inherits="Password.Masters.UserMaster" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" /> <script src="http://code.jquery.com

How to get the ScriptManager of Master Page into Child page's code behind c# (.cs) file

橙三吉。 提交于 2019-11-29 11:39:57
问题 Following is the web site environment I created: I have a Master page. I have created a Child page from it. I have placed Script Manager on the Master page. Now I want to access that Master page's Script Manager to create a User Control dynamically in my code behind (C#) file. How can I access Script Manager placed on master page to my child page. 回答1: I got it, its given in ScriptManager class itself. System.Web.UI.ScriptManager.GetCurrent(this.Page); 回答2: Not sure what exactly you want here

Only Content controls are allowed directly in a content page that contains Content controls in ASP.NET

徘徊边缘 提交于 2019-11-29 10:42:20
问题 I have an application which has a master page and child pages. My application is working fine on local host (on my intranet). But as soon as I put it on a server that is on the internet, I get the error shown below after clicking on any menus. Only Content controls are allowed directly in a content page that contains Content controls. 回答1: Double and triple check your opening and closing Content tags throughout your child pages. Confirm that they are in existence are spelled correctly have an