how to view master page in browser

眉间皱痕 提交于 2019-12-23 09:48:05

问题


just learning master page, i have a master page which include a content. but how to view the page .master in browser? what it the url?

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

回答1:


No, you can not view master page (.master) in browser - because it is not an actual page but a Control which encloses the content of .aspx pages.

When users request the content pages(.aspx), they merge with the master page (.master) to produce output that combines the layout of the master page with the content from the content page.

A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.

For more information please read - ASP.NET Master Pages




回答2:


you can use it alone in aspx page and view the aspx page directly




回答3:


You can not directly view a master page. It's more like a shell\template of what the page is supposed to look like.

However, you can create a new page using the master page you have here, and call that page's Url.




回答4:


You cannot view a master page in the browser. It is not a renderable page.

The master page is referenced by regular .aspx pages with the Master attribute of the @Page directive. The rendering process merges the contents of the page and the master and the results are returned to the client, but the URL is that of the page.

If you wish to see the master page as it is rendered, create an empty page that uses that master, then view the page in your browser.




回答5:


Run This Default2.aspx page to show this page content into master page.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    This Is Your Master Page Content....
</asp:Content>


来源:https://stackoverflow.com/questions/13046052/how-to-view-master-page-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!