0

每个人都是 ASP .net 的新手,我不知道如何使用 ASP .net 来创建母版页,请帮帮我


这是我的Masterpage标记:

<%@ 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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;<table style="width: 874px; height: 592px">
            <tr>
                <td colspan="3" style="height: 9px">
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                    <asp:Label ID="Label1" runat="server" Font-Size="X-Large" ForeColor="#C0C000" Text="Sarth Enterprises"></asp:Label></td>
            </tr>
            <tr>
                <td colspan="2" style="height: 15px">
                    <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
                        <Items>
                            <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
                            <asp:MenuItem Text="Products" Value="Products">
                                <asp:MenuItem Text="AE" Value="AE"></asp:MenuItem>
                                <asp:MenuItem Text="RSQE" Value="RSQE"></asp:MenuItem>
                                <asp:MenuItem Text="Comp. Hardware" Value="Comp. Hardware"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Contact us" Value="Contact us"></asp:MenuItem>
                            <asp:MenuItem Text="About us" Value="About us"></asp:MenuItem>
                            <asp:MenuItem Text="FAQ" Value="FAQ"></asp:MenuItem>
                        </Items>
                    </asp:Menu>
                </td>
                <td style="width: 106px; height: 15px">
                </td>
            </tr>
            <tr>
                <td style="width: 212px">
                    <br />
                    <asp:Label ID="Label3" runat="server" Text="Member Login"></asp:Label><br />
                    <br />
                    <br />
                    <asp:Label ID="Label4" runat="server" Text="User ID:"></asp:Label>
                    &nbsp; &nbsp; 
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    &nbsp; &nbsp;
                    <br />
                    <br />
                    <br />
                    <asp:Label ID="Label5" runat="server" Text="Password"></asp:Label>
                    &nbsp; &nbsp;
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                    <br />
                    <br />
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    <asp:Button ID="Button1" runat="server" Text="Login" /><br />
                    <br />
                    <br />
                    <asp:Label ID="Label6" runat="server" Text="For new member,"></asp:Label>
                    <asp:HyperLink ID="HyperLink1" runat="server">Sign UP</asp:HyperLink></td>
                <td style="width: 257px">
                </td>
                <td style="width: 106px">
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp;
                    <asp:Label ID="Label2" runat="server" Font-Bold="True" ForeColor="#C0C000" Height="19px"
                        Text="Copy right ,resereved @ Sarth enterprises" Width="284px"></asp:Label></td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
4

3 回答 3

0

母版页允许您定义整个网站的外观。以下链接来自微软。去看一下:

ASP.NET 母版页概述

母版页教程

于 2010-03-13T16:13:43.493 回答
0

从此MSDN 页面(演练:在 Visual Web Developer 中创建和使用 ASP.NET 母版页)

  • 在解决方案资源管理器中,右键单击您的网站名称,然后单击“添加新项目”。
  • 在 Visual Studio 安装的模板下,单击母版页。
  • 在名称框中,键入 Master1。
  • 选中将代码放在单独的文件中复选框。
于 2010-03-13T16:13:56.630 回答
0

从创建 Oded 提供的母版页开始,您想要离开“contentPlaceholders”。您可以根据需要添加更多内容。这是您的派生页面将使用的位置。

当您准备好基于母版页创建页面时,单击为您的项目添加新表单,单击复选框以使用“母版页”,并为其指定要创建的新表单的名称。当您单击确定时,它将提示您希望它基于哪个母版页(您实际上可以创建许多母版页)。一旦被选中并且您处于设计模式,它将以灰色的外观显示您,实际内容来自“母版页”,内容占位符是您放置特定于该页面的内容的位置。表格、网格、标签等等。保存并运行,您将看到您的内容。然后,调整母版页并放入公司徽标图形之类的内容,保存并运行您的第二个表单,您会看到它现在具有新添加的徽标。

希望这能阐明它们是如何工作的......此外,您可以将 CSS 文件拖放到母版页上,以全面应用样式格式。

于 2010-03-13T16:26:31.470 回答