master-pages

How to Determine duplicate Javascript Functions which include in Asp.net Page

强颜欢笑 提交于 2019-12-03 15:54:58
I have an application which use some javascript functions, As all javascripts include in Masterpage, most of them which comes withpage are not necessary, and some of those are repeated ( cause used in some different JS file. ) So I want to check if there is a way to determine duplicate functions and remove them ? You can check if the function exists when declaring a function, but You have to change the way it works. instead of function foo(){ something } do if(window.foo===undefined){ window.foo=function(){ something } } and You can still call it foo(); All this can be added in Your files with

Access Master Page public method from user control/class/page

我的梦境 提交于 2019-12-03 15:06:46
I am to access a method on my master page. I have an error label which I want to update based on error messages I get from my site. public string ErrorText { get { return this.infoLabel.Text; } set { this.infoLabel.Text = value; } } How can I access this from my user control or classes that I set up? Page should contain next markup: <%@ MasterType VirtualPath="~/Site.master" %> then Page.Master will have not a type of MasterPage but your master page's type, i.e.: public partial class MySiteMaster : MasterPage { public string ErrorText { get; set; } } Page code-behind: this.Master.ErrorText = .

CSS and images on Master Page

江枫思渺然 提交于 2019-12-03 14:54:41
I have this quite popular problem, but have failed to find a solution that works. Basicly, I am using a Master Page (/Masterpages/Default.master), that includes <link href="../css/style.css" rel="stylesheet" type="text/css /> And it also includes some images with the same relative linking. But when I apply the Master Page to content pages (in diffrent folderlevels) the css formating and images is lost. Is there anyway to dynamicaly solve the folderlevel links to css and images to all content pages using the masterpage? Thanks in advance UPDATE: There is an additional problem. It's tricky to

Remove ctl00$ContentBody$ from rendered control ID

浪尽此生 提交于 2019-12-03 14:39:56
I made some changes to an existing application that was previously just straight HTML and Javascript. To add server-side functionality, I chose ASP.NET, and took advantage of the Master Page concept. Unfortunately, on one huge web form, the control IDs are all mangled with the "ctl00$ContentBody$" prefix. I tacked a runat="server" on all the INPUT controls which is what altered the IDs. Now that the IDs have been changed, the Javascript (which is so poorly written I can't even read it, and I'm quite experienced with JS) is completely broken. So, how can I prevent this nonsense from being

How should I integrate session state into an ASP.NET MVC application?

ぃ、小莉子 提交于 2019-12-03 13:56:45
I'm looking for thoughts on how should I use Session in an ASP.NET MVC application? Especially when using masterpages and tryin to just get the data to the masterpage without bypassing the controller. This question started off by me asking a lot of little questions, but then I managed to mould it into a solution which as yet I have not implemented but one which is somewhat workable. Would appreciate any feedback. My proposed solution aka 'what i am about to implement unless someone says stop!' I have my model classes inheriting from ModelBase -- which contains the information needed by the

How to set Page's Title from a web content page in ASP.NET 3.5

为君一笑 提交于 2019-12-03 12:34:49
I've read through quite a bit of posts/articles on how to do this and I still am not getting the page title set from the content page. My pages render OK except I can't get the title set from the content page (all the page's have Title set as per the master page). Here's the codebehind for my master page: Partial Class zSEO Inherits System.Web.UI.MasterPage Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Page.Header.Title = "Dynamically set in Master page" End Sub End Class Here is the rest of the master page: <%@ Master Language="VB" EnableTheming="true" Inherits=

Master page in HTML

眉间皱痕 提交于 2019-12-03 10:47:41
问题 Is there any way to create a similar idea as master/content page in ASP.NET in pure HTML? I want to create several pages in HTML, but I want that all of them look the same with some contents different. Is there any way to do this without creating several pages which are very similar to each other? 回答1: //wait until the dom is loaded $(document).ready(function () { //adds menu.html content into any "#menu" element $('#menu').load('menu.html'); }); In reference to some of the other answers,

Page losing title after UpdatePanel asyncpostback

感情迁移 提交于 2019-12-03 10:43:57
I have just noticed recently that my page title will reset to the standard "Untitled Page" after I perform an asyncpostback from inside my UpdatePanel in the main page. The title will not be lost during a postback from inside the master page (such as when I click on the search box button inside the master page). I assumed that by using a different contentplaceholder specifically for setting the document title I was going to avoid issues like this, but apparently I was wrong. Is there something else I am missing other than having to explicitly set the title in the code-behind of the ASPX page

Setting an ASP.NET Master Page at runtime

萝らか妹 提交于 2019-12-03 10:42:39
问题 I'm working on a site which needs to be able to support two or more looks, changable at runtime. I'd hoped to be able to handle the change with a CSS switch, but it looks like I'll need to use a different masterpage for each design. So, what's the best way to set the masterpage at runtime? Page.MasterPageFile can only be set in the Page.OnPreInit event. It looks like the solutions are to make all my pages inherit from a common base which handles the PreInit event, or to use an HttpModule

Best way to wire up database-driven menu in ASP.NET MVC

☆樱花仙子☆ 提交于 2019-12-03 08:51:57
问题 I'm looking for a way to handle a database-driven menu in ASP.NET MVC that doesn't violate the MVC principles. I want to replace the hard-coded, default, "Home, About" menu with something from my database. How would I wire this up? Would I just set up a ContentPlaceHolder in my Site.Master and have regenerated in my Views? That doesn't seem right to me. 回答1: My main menu is a ViewUserControl that is rendered as a partial view in my MasterPage. Although mine is hard-coded, you could easily