master-pages

ASP.NET Master Page Content Page's IDs all changed, breaking CSS based on original element IDs? Are you kidding me

我的梦境 提交于 2019-12-19 03:58:19
问题 ASP.NET Master Page Content Page's elements all seem to be having their ID's changed or prepended by the ASP.NET page renderer. This breaks all CSS styles based on the original element IDs. Is this seriously how it works? If so, is there a way around it? 回答1: Yes, you can specify the ClientIDMode set it to static. examples : Client Side <asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox> Code Behind TextBox txtBox = new TextBox(); txtBox.ID = "TextBox1"; txtBox

ASP.NET MVC getting last modified date/FileInfo of View

核能气质少年 提交于 2019-12-19 03:54:06
问题 I'm required to include the last modified date on every page of my applications at work. I used to do this by including a reference to <%= LastModified %> at the bottom of my WebForms master page which would return the last modified date of the current .aspx page. My code would even check the associated .aspx.cs file, compare the last modified dates, and return the most recent date. Does anyone know if you can read the FileInfo of a MVC View? I would like to include it in the master page, if

Get ControllerName and ActionName and populate the ViewData in Master Page?

五迷三道 提交于 2019-12-18 13:53:22
问题 I've a SuperController which will be inherited from all the controllers. In the constructor I'm trying to populate the ViewData using the ControllerName and the ActionName. I'm not going to pass the ControllerName and the ActionName as the ViewData. I've a method that needs the ControllerName and the ActionName and I need to pass the return value of the method as the ViewData. How can I do that? 回答1: Don't use ViewData . Use this in your Site.Master instead: <%= ViewContext.RouteData.Values[

Redirect to controller (but with a different master) using a catchall wildcard

大城市里の小女人 提交于 2019-12-18 13:38:30
问题 I have a problem whereby I want to display a view differently (a different master page), depending on where it came from, but don't know where to start... I have several routes which catch various different types of urls that contain different structures. In the code snippet below, I have a product route, and then I have a partner site route which could also go to a product page, but let's say that this partner is Pepsi, and they want their branding on the master page, rather than our own

MVC Layout VS MVC Master Page

£可爱£侵袭症+ 提交于 2019-12-18 12:12:37
问题 I'm starting learning MVC4. I came across the two possibilities of creating a View based on a Razor template or a Master Page. I would like to understand the practical differences between the two . For now, I can see that if I create a View using a Master Page, I can override several sections. For example, if my Master defines a "left column" placeholder and a "body" placeholder I can not only define the body for a specific View, but I can also render contents in the "left column" section for

How to set the default button in content page using asp.net?

戏子无情 提交于 2019-12-18 05:41:24
问题 I need to set the content page default button. My code is like this: <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" defaultbutton="BtnSearch" defaultfocus="TxtSearchValue"> It is working fine, but my master page menu have one image button like chat, I can press the enter key to fire image button click event but it does not fire default button in content page. How to handle this type of issue? 回答1: 1) You simply have to do: this.Form.DefaultButton = this.btnId

How to set the default button in content page using asp.net?

时光总嘲笑我的痴心妄想 提交于 2019-12-18 05:41:10
问题 I need to set the content page default button. My code is like this: <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" defaultbutton="BtnSearch" defaultfocus="TxtSearchValue"> It is working fine, but my master page menu have one image button like chat, I can press the enter key to fire image button click event but it does not fire default button in content page. How to handle this type of issue? 回答1: 1) You simply have to do: this.Form.DefaultButton = this.btnId

How do I reference an ASP.net MasterPage from App_Code

♀尐吖头ヾ 提交于 2019-12-18 05:07:38
问题 I'm working on a .net 3.5 site, standard website project. I've written a custom page class in the sites App_Code folder (MyPage). I also have a master page with a property. public partial class MyMaster : System.Web.UI.MasterPage { ... private string pageID = ""; public string PageID { get { return pageID; } set { pageID = value; } } } I'm trying to reference this property from a property in MyPage. public class MyPage : System.Web.UI.Page { ... public string PageID { set { ((MyMaster)Master)

How do I reference an ASP.net MasterPage from App_Code

纵然是瞬间 提交于 2019-12-18 05:07:32
问题 I'm working on a .net 3.5 site, standard website project. I've written a custom page class in the sites App_Code folder (MyPage). I also have a master page with a property. public partial class MyMaster : System.Web.UI.MasterPage { ... private string pageID = ""; public string PageID { get { return pageID; } set { pageID = value; } } } I'm trying to reference this property from a property in MyPage. public class MyPage : System.Web.UI.Page { ... public string PageID { set { ((MyMaster)Master)

Find a UnorderedList <UL> control inside a master page from a content page in asp.net

不羁的心 提交于 2019-12-18 04:54:16
问题 Hai guys, I want to find a UL control and then find a LI within that UL and assign a css class to that from a content page.... <ul id="mainMenu" runat="server" style="width:350px;"> <li id="mainHome" runat="server"><a title="Home" href="#" class="home">Home</a></li> <li id="mainManage" runat="server"><a title="Manage" href="#" class="manage">Manage</a></li> <li id="mainEnquiry" runat="server"><a title="Enquiry" href="#" class="enquiry">Enquiry</a></li> <li id="mainReport" runat="server"><a