子文件夹中的Web表单会产生问题 [英] webforms in subfolders creating problems

查看:51
本文介绍了子文件夹中的Web表单会产生问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我只想了解为什么会这样.考虑一下,
我有一个母版页(ClientMaster),一个引用了ClientMaster的嵌套母版页(Homenested).
现在,我在根文件夹中有一个名为Webforms的文件夹.在此文件夹中,有许多子文件夹...
例如说Homepage文件夹(位于Webforms文件夹内),其中有一个homepage.aspx页面,该页面引用Homepagenested嵌套母版页.在这种情况下,运行homepage.aspx页面时,
嵌套的母版页和Clientmasterpages样式变得一团糟,我的意思是所有侧边菜单的正确内容等都错位了.
令我震惊的是,当我直接在Webforms文件夹下而不是在子文件夹中创建一个aspx页面时,样式保持不变,就像什么也没发生一样.

我喜欢让事情井井有条,这就是为什么我要创建子文件夹来对Web表单进行分组的原因....但这对我来说并不奏效.

请,任何帮助将不胜感激.我没有考虑在此处放置任何代码,因为我的问题仅与路径有关...我想,但是如果您需要将代码用于
更好地了解我的问题...然后我很乐意将它们放在这里


已编辑

这是我在ClientMaster.Master页面中链接样式表的方式

< link rel = "  href = " /> 



在我的NestedMasterpage中,

 <%@    母版   语言  ="  C#"  MasterPageFile   〜/MasterPages/ClientMaster.master"  AutoEventWireup   ="   CodeFile    PlanYourTravelNested .master.cs" 继承   MasterPages_PlanYourT ravelNested" %> 

< asp:Content ID = "  ContentPlaceHolderID =  "  Runat = "  > 
    < link rel = "  href = "  ../Style/NestedStyle.css"/>
    < asp:ContentPlaceHolder ID = "  runat =  "  > 
    </  asp:ContentPlaceHolder  > 
</  asp:Content  >  


子文件夹中引用NestedMaster页面的.aspx页面,

 <%@    页面   语言  ="  C#"  AutoEventWireup    true"  MasterPageFile   ="   CodeFile    PlanYourTravel .aspx.cs"    继承  ="  WebForms_Plan_Your_Trave l_PlanYourTravel" 标题  计划行程" %>  



这就是链接标记在我的内容页面中的外观.正如您在HTML文件中看到的,Masterpages文件夹(位于根文件夹中)...它在两个目录中....
FYI .... i使用ResolveUrl(〜/Style/ClientStyle.css")链接母版页中的样式表.

 <  链接    rel   ="     href   ="  类型  文本/css" / 解决方案

如果您要使用同一母版使用一堆嵌套文件夹,请确保母版页面上包含的css和js正在使用到源的完整路径,而不是相对路径.

 <  链接   类型  ="     href   =" /YourContentFolder/YourCss.css"  rel   ="    >  


不是

 <  链接   类型  ="     href   ="  YourContentFolder/YourCss.css"  rel   ="    >  



 <  链接   类型  ="     href   ="  ../YourContentFolder/YourCss.css"  rel   ="    < head runat = "  </ 标题 > 
    < link href = "  rel =  样式表" type =  />
    < asp:contentplaceholder id = "  runat =  "  xmlns:asp = "  > 
    </  asp:contentplaceholder  > 
</  >  


Hello all, i just want to understand why this is happening. Consider this,
I have a masterpage(ClientMaster), a nested masterpage(Homepagenested) that references the ClientMaster.
Now, i have a folder named Webforms in the root folder. Inside this folder there are many subfolders...
say Homepage folder(Inside the Webforms folder) where there is a homepage.aspx page that references the Homepagenested Nested masterpage.In this case, when running the homepage.aspx page the
Nested masterpages and the Clientmasterpages styles goes haywire, i mean all the sidemenubars the right contents etc...are all out of place.
The shocking thing to me is that, when i create an aspx page directly under Webforms folder and not in the subfolders, the styles are maintained as if nothing happened.

I like to Keep things organized that''s why i create subfolders for grouping the webforms....but it''s just not working out for me.

Please, any kind of help would be appreciated. I didn''t think of placing any codes here since my problem is just related to paths...i guess, but if you need the codes to
understand my problem better...then i''ll be happy to place them here


EDITED

This is the way i''ve linked my stylesheet in ClientMaster.Master page

<link rel="Stylesheet" href="../Style/ClientStyle.css"/>



in my NestedMasterpage,

<%@ Master Language="C#" MasterPageFile="~/MasterPages/ClientMaster.master" AutoEventWireup="false" CodeFile="PlanYourTravelNested.master.cs" Inherits="MasterPages_PlanYourTravelNested" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link rel="Stylesheet" href="../Style/NestedStyle.css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>


the .aspx page in the subfolder that references the NestedMaster page,

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPages/PlanYourTravelNested.master" CodeFile="PlanYourTravel.aspx.cs" Inherits="WebForms_Plan_Your_Travel_PlanYourTravel" Title="Plan Your Travel" %>



this is how the link tag looks in my content pages. As you can see in the HTML file the Masterpages folder(which is in the root folder)...it is going up two directories....
FYI....i used ResolveUrl("~/Style/ClientStyle.css") to link the style sheet in the master page.

<link rel="Stylesheet" href="../../MasterPages/%3C%25=ResolveUrl(%22~/Style/ClientStyle.css%22)%20%25%3E" type="text/css" />

解决方案

If you want to use a bunch of nested folders with the same master, ensure that your css and js includes that exist on the master page are using full paths to the source instead of relative paths.

<link type="text/css" href="/YourContentFolder/YourCss.css" rel="stylesheet" />


NOT

<link type="text/css" href="YourContentFolder/YourCss.css" rel="stylesheet" />


or

<link type="text/css" href="../YourContentFolder/YourCss.css" rel="stylesheet" />


solution provided by @Marcus is correct but i want to add one more point here
->you are facing this problem because your CSS not linked in Site.Master page correctly.

<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:contentplaceholder id="HeadContent" runat="server" xmlns:asp="#unknown">
    </asp:contentplaceholder>
</head>


这篇关于子文件夹中的Web表单会产生问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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