[新手]导航问题 [英] [newbie] navigation problems

查看:93
本文介绍了[新手]导航问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET 3.5(VS 2008)运行此网站模板,并且我注意到asp:Content中的内容向下滚动到页面底部,而我想写空白.

另外,我希望顶部导航和左侧导航之间不要有空格,这可能吗?

此处上查看网站的屏幕快照,并且源代码在

I''m running this website template using ASP.NET 3.5 (VS 2008) and, I''ve noticed that the content within asp:Content scrolls down to the bottom of the page, whilst I would like to write in the white space.

Also, I would like the top navigation and left navigation not to have a white space between them, is this possible?

See screenshots of site at here, and, source code is available here.

Masterpage.master

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



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> 
    <title>Jon''s Couch</title>
    <asp:contentplaceholder id="head" runat="server" xmlns:asp="#unknown">
    </asp:contentplaceholder>
</head>
<body>
    <form id="form1" runat="server">
    </form>
       <h1>Jon''s Couch</h1>
        <p style="width: 122px; height: 663px; margin-top: 0px; margin-right: 0px;">
        <a href="About.aspx">About me</a> <br />
        <a href="Diary.aspx">My diary</a> <br />
        <a href="Articles.aspx">Articles</a> <br />
        <a href="Bookmarks.aspx">My bookmarks</a> <br />
        <a href="Promotions.aspx">Promotions</a> <br />
        <a href="Resume.aspx">My resume</a> <br />
        <a href="Warez.aspx">Filesharing</a> <br />
        </p>
        <asp:contentplaceholder id="body" runat="server" xmlns:asp="#unknown">
            This page is still under construction. 
           //this shows at the bottom
        </asp:contentplaceholder>
        </body>
</html>



我还注意到,尽管我将< title>设置为标签在母版页中,则不会显示在Google Chrome或IE8中.实际上,没有< title>标记显示在default.aspx的HTML源代码中.这是一个错误吗?



I''ve also noted that although I set the <title> tag within the master page, this does not show up within Google Chrome, or IE8. As a matter of fact no <title> tag is displayed within the HTML source of default.aspx. Is this a bug?

<html xmlns="http://www.w3.org/1999/xhtml">
<head><link href="StyleSheet.css" rel="stylesheet" type="text/css" /><title>
	Untitled Page
</title>
</head>
<body>
    <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkw9GhFk7Jm0d18GGgcCWptFrhuhY=" />
</div>
 
    </form>
       <h1>Jon''s Couch</h1>
        <p style="width: 122px; height: 663px; margin-top: 0px; margin-right: 0px;">
        <a href="About.aspx">About me</a> <br />
        <a href="Diary.aspx">My diary</a> <br />
        <a href="Articles.aspx">Articles</a> <br />
        <a href="Bookmarks.aspx">My bookmarks</a> <br />
        <a href="Promotions.aspx">Promotions</a> <br />
        <a href="Resume.aspx">My resume</a> <br />
        <a href="Warez.aspx">Filesharing</a> <br />
        </p>
        
This is my webpage, where I write about anything that sparks my interest.
The page is still under construction.
 
        </body>
</html>



我随机:)尝试添加< title>标记在Default.aspx中,但是当我这样做时,html页面崩溃并显示以下错误:

解析器错误
说明:在解析服务于此请求所需的资源期间发生错误.请查看以下特定的解析错误详细信息,并适当地修改您的源文件.

解析器错误消息:在包含内容控件的内容页面中,仅直接允许内容控件.

源错误:

第1行:
第2行:
第3行:< title>乔恩的沙发

http://localhost/Jon%27s%20Couch/Default.aspx

:confused:

注意:乔恩的沙发(ASP.NET)



I randomly :) tried adding a <title> tag within Default.aspx, however when I do this the html page crashes with the following error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

Source Error:

Line 1:
Line 2:
Line 3: <title>Jon''s Couch

http://localhost/Jon%27s%20Couch/Default.aspx

:confused:

NOTE: Jon''s Couch (ASP.NET)

推荐答案

好,以下是修复程序:

1.页面标题问题:



如果在Asp.net中使用母版页,则需要在每个页面的代码隐藏"文件中设置页眉"标题,而不是在ASPX页面中设置标题".因此,这是您需要做的事情:

-从Default.aspx中删除以下代码行

OK, following are the fixes:

1. Page Title problem:



If you use Master Pages in Asp.net, you need to set Pate title in each page''s Code Behind file, instead of setting the Title in ASPX page. So, here is the things you need to do:

--Remove the following line of code from Default.aspx

<title>Jon''s Couch</title>



-在Default.aspx的CodeBehind中添加以下代码



--Add the following code in the CodeBehind of Default.aspx

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "Jon's Couch";
    }
}



现在您将看到,页面标题正确显示在每个浏览器中:)


2.内容向下滚动问题:




基本上,您在MasterPage和Default.aspx中有错误的HTML.我已更正了这些内容:

更正的母版页代码:



Now you will see, page title is correctly appearing in each browser :)


2. Content scrolling down problem:




Basically, you had wrong HTML in MasterPage and Default.aspx. I have corrected those:

Corrected MasterPage code:

<%@ 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">
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <title>Jon's Couch</title>
</head>
<asp:contentplaceholder id="head" runat="server">
</asp:contentplaceholder>
<body>
    <form id="form1" runat="server">
    <h1>
        Jon's Couch
    </h1>
    <div style="float: left; width: 122px">
        <p style="width: 122px; height: 663px; margin-top: 0px; margin-right: 0px;">
            <a href="About.aspx">About me</a>
            <br />
            <a href="Diary.aspx">My diary</a>
            <br />
            <a href="Articles.aspx">Articles</a>
            <br />
            <a href="Bookmarks.aspx">My bookmarks</a>
            <br />
            <a href="Promotions.aspx">Promotions</a>
            <br />
            <a href="Resume.aspx">My resume</a>
            <br />
            <a href="Warez.aspx">Filesharing</a>
            <br />
        </p>
    </div>
    <div style="float: right">
        <asp:ContentPlaceHolder ID="body" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    <div style="clear: both">
    </div>
    </form>
</body>
</html>




更正了Default.aspx代码:




Corrected Default.aspx code:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
This is my webpage, where I write about anything that sparks my interest.
The page is still under construction.
</asp:Content>




3.顶部和左侧导航之间的差距问题:




修改StyleSheet.css中的h1类,如下所示:




3. Gap issue between top and left navigation:




Modify the h1 class in the StyleSheet.css as follows:

h1
{
    color:#254117;
    background-color:#4AA02C;
    text-align:right;
    font-family:Arial;
    margin:0px;
}



我刚刚添加了"margin:0px" ,将h1标签的边距设置为0px

完成这些修改后,点击 ctrl + f5 浏览Default.aspx,您所有的问题都将消失.

您可以在CodeProject上查看MasterPage教程(
ASP.NET 2.0母版页 [ ^ ])

不用担心,Asp.net很容易.享受吧!



I just added the "margin:0px" to set the margin of h1 tag to 0px

After doing these modifications, hit ctrl+f5 to browse the Default.aspx and all your problems will be blown away.

You can have a look at a MasterPage tutorial here at CodeProject (ASP.NET 2.0 Master Pages[^])

Don''t worry, Asp.net is easy. Enjoy!


这篇关于[新手]导航问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆