CSS采空工作asp.net [英] css stoped working asp.net

查看:89
本文介绍了CSS采空工作asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重新张贴问题,因为它,因为我与它最初的问题已经改变了很多,我知道问题出在哪里,但我不知道如何解决它,还是它的原因的。

所以,我有2个主文件,一个是登录页面,另一个用于内部的内容。我也有一个Default.aspx文件和logout.aspx文件。它们都使用MasterPage.master这是初始页面。我发现了什么,当我从项目排除Logout.aspx并运行它,网站初始页面使用.css文件。当我包括logout.aspx调试程序,初始屏幕采用起初然后当我登录和注销的CSS,这表明没有.css中的Default.aspx。如果我再次尝试调试页面,则初始屏幕不再使用的CSS。

我的主人类有这样的:

 <%@主语言=C#AutoEventWireup =真codeFILE =MasterPage.master.cs继承=母版%GT;!< D​​OCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<头=服务器>
    <标题>< /标题>
    <链接HREF =〜/ stylesheet.css中相对=样式类型=文/ CSS/>
    < ASP:的ContentPlaceHolder ID =头=服务器>
    < / ASP:&的ContentPlaceHolder GT;
< /头><身体GT;
    <形式=服务器>
        < D​​IV CLASS =登陆GT&;
            < D​​IV CLASS =容器>
               < D​​IV CLASS =头>
                   < H1 ID =网站名称>
                        <字体颜色=黑大小=5> SES用户管理< / FONT>
                   < / H1>
                < / DIV>
                 <! - 你好内容 - >
                < D​​IV CLASS =内容>
                        < ASP:标签ID =lblUsername=服务器文本=用户名>< / ASP:标签>
                        &安培; NBSP;&安培; NBSP;&安培; NBSP;
                        < ASP:文本框ID =txtUsername=服务器HEIGHT =21px
                            风格=保证金左:2px的WIDTH =133px>< / ASP:文本框>
                        < BR />< BR />
                        < ASP:标签ID =lblPassword=服务器文本=密码>< / ASP:标签>
                        &安培; NBSP;&安培; NBSP;&安培; NBSP;
                        < ASP:文本框ID =txtPassword=服务器的TextMode =密码HEIGHT =20像素
                            风格=保证金左:4PXWIDTH =133px>< / ASP:文本框>
                        < BR />< BR />
                        < D​​IV CLASS =按钮>
                        < ASP:标签ID =lblResult=服务器WIDTH =100%>< / ASP:标签>
                            < ASP:按钮的ID =btnLogin=服务器文本=登录的OnClick =btnlogin_Click
                                WIDTH =57pxHEIGHT =21px/>
                        < / DIV>
                < / DIV>            < / DIV>        < / DIV>
            < ASP:的ContentPlaceHolder ID =日程地址搜索Maincontent=服务器/>
    < /表及GT;
< /身体GT;
< / HTML>

默认的aspx和default.cs都是空的,像这样:

 <%@页标题=主页LANGUAGE =C#的MasterPageFile =〜/ MasterPage.masterAutoEventWireup =真
        codeFILE =Default.aspx.cs继承=_默认%GT;    < ASP:内容ID =HeaderContent=服务器ContentPlaceHolderID =头>
    < / ASP:内容>
    < ASP:内容ID =MainerContent=服务器ContentPlaceHolderID =日程地址搜索Maincontent>    < / ASP:内容>

除了除了包含注销功能logout.aspx.cs注销:

 <%@页标题=主页LANGUAGE =C#的MasterPageFile =〜/ MasterPage.masterAutoEventWireup =真
    codeFILE =Logout.aspx.cs继承=注销%GT;< ASP:内容ID =HeaderContent=服务器ContentPlaceHolderID =头>
< / ASP:内容>
< ASP:内容ID =MainerContent=服务器ContentPlaceHolderID =日程地址搜索Maincontent>< / ASP:内容>

CS

 使用系统;
使用System.Data这;
使用System.Configuration;
System.Collections中使用;
使用的System.Web;
使用System.Web.Security;
使用System.Web.UI程序;
使用System.Web.UI.WebControls;
使用System.Web.UI.WebControls.WebParts;
使用System.Web.UI.HtmlControls;
使用HELLOAPP;公共部分类注销:页
{
    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        FormsAuthentication.SignOut();
        的Response.Redirect(Default.aspx的);    }
}


解决方案

我怀疑你的的site.css 不在同一文件夹中的母版/ ContentPage。

如果您链接到样式表仅仅是的site.css 然后什么都文件夹中的母版/ ContentPage或只是ContentPage在将寻找在样式表文件夹中。

例如。如果使用<链接rel =stylesheet属性类型=文/ CSS的href =的site.css/>

  /Folder1/ContentPage.aspx将寻找/Folder1/Site.css

如果你改变你的样式表使用<链接rel =stylesheet属性类型=文/ CSS的href =/的site.css/> 然后您的网站将查找在根目录下的样式表。但是,如果你的网站正在运行的

`的http://本地主机:1234 / WebsiteFolder / ContentPage

WebsiteFolder,然后有 /Site.css 将寻找WebsiteFolder外面的CSS文件

请发表您的网站的文件夹结构,您的网站是否也与虚拟路径运行。要找到虚拟路径,查看属性的网站。

I am reposting the question, since it has changed a lot since I had problems with it initially, I know where the problem is but i do not know how to fix it, or the cause of it at all.

So i have 2 master files, one is for a login page and another one for the inside content. I also have a default.aspx file and a logout.aspx file. They both use the MasterPage.master which is the initial page. What i found out is, when I exclude the Logout.aspx from the project and run it, the website initial page uses the .css file. When I include the logout.aspx debug the program, the initial screen uses the .css at first then when i log in and log out, it shows the default.aspx without the .css. If I try to debug the page again, then the initial screen no longer uses the .css.

My master class has this:

<%@ 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>
    <link href="~/StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

<body>
    <form runat="server">
        <div class="login">
            <div class="container">
               <div class="header">
                   <h1 id="site-name">
                        <font color="black" size="5">SES Users Admin</font>
                   </h1>
                </div>
                 <!--Hello Content -->
                <div class="content">
                        <asp:Label ID="lblUsername" runat="server" Text="Username"></asp:Label>
                        &nbsp;&nbsp;&nbsp;
                        <asp:TextBox ID="txtUsername" runat="server" Height="21px" 
                            style="margin-left: 2px" Width="133px"></asp:TextBox>
                        <br /><br />
                        <asp:Label ID="lblPassword" runat="server" Text="Password"></asp:Label>
                        &nbsp;&nbsp;&nbsp;
                        <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Height="20px" 
                            style="margin-left: 4px" Width="133px"></asp:TextBox>
                        <br /><br />
                        <div class="button">
                        <asp:label id="lblResult" runat="server" Width="100%"></asp:label>
                            <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnlogin_Click" 
                                Width="57px" Height="21px"/>
                        </div>
                </div>

            </div>

        </div>
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
    </form>
</body>
</html>

Default aspx and default.cs are both empty like so:

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

    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="head">
    </asp:Content>
    <asp:Content ID="MainerContent" runat="server" ContentPlaceHolderID="MainContent">

    </asp:Content>

As well as logout except for the logout.aspx.cs which contains the logout function:

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

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="head">
</asp:Content>
<asp:Content ID="MainerContent" runat="server" ContentPlaceHolderID="MainContent">

</asp:Content>

CS

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HelloApp;

public partial class Logout : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Response.Redirect("default.aspx");

    }
}

解决方案

I suspect that your Site.css is not in the same folder as your MasterPage/ContentPage.

If your link to the stylesheet is simply Site.css then what ever the folder your MasterPage/ContentPage or just the ContentPage is in will be looking for the stylesheet in that folder.

e.g. if using <link rel="Stylesheet" type="text/css" href="Site.css" />

/Folder1/ContentPage.aspx will be looking for /Folder1/Site.css

If you change your stylesheet to using <link rel="Stylesheet" type="text/css" href="/Site.css" /> Then your website will look for the stylesheet in the root directory. HOWEVER, if your website is running as

`http://localhost:1234/WebsiteFolder/ContentPage'

"WebsiteFolder", then having /Site.css will look for the css file outside of the "WebsiteFolder"

Please post the folder structure of your site, also whether your site is running with a Virtual Path. To find the Virtual Path, view the properties for the website.

这篇关于CSS采空工作asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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