GVKun编程网logo

向asp.net添加样式表(使用Visual Studio 2010)(asp.net style)

20

这篇文章主要围绕向asp.net添加样式表(使用VisualStudio2010)和asp.netstyle展开,旨在为您提供一份详细的参考资料。我们将全面介绍向asp.net添加样式表(使用Visu

这篇文章主要围绕向asp.net添加样式表(使用Visual Studio 2010)asp.net style展开,旨在为您提供一份详细的参考资料。我们将全面介绍向asp.net添加样式表(使用Visual Studio 2010)的优缺点,解答asp.net style的相关问题,同时也会为您带来ASP.NET MVC 4 for Visual Studio 2010 下载地址、asp.net – Visual Studio 2008,2010或2012(v11)是否写入使用多核?、asp.net – Visual Studio 2010中的HTML格式、asp.net – Visual Studio 2010和Visual Studio 2012中的col,colgroup,tbody和thead throws编译错误的HTML表标记的实用方法。

本文目录一览:

向asp.net添加样式表(使用Visual Studio 2010)(asp.net style)

向asp.net添加样式表(使用Visual Studio 2010)(asp.net style)

我正在尝试将样式表添加到asp.net Web表单中的母版页.基本上尝试为页面顶部创建内联导航菜单.我遇到了问题.我已经创建了样式表(如果这是一个html站点,我会创建相同的方式)并且我已将它放在您在下面看到的目录中.我不知道下面的代码如何显示样式表的任何关系.

就像在HTML中一样,我会的
    
      >家
      >关于
      >联系
    

然后我的样式表看起来像这样……

ul {
list-style-type:none;
margin:0;
padding:0;
}

li {
display:inline;
padding:20px;
}

CSS会让它显示为内联(顶部).但我不知道该去哪里.

<%@ 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>AR ToolBox</title>
<asp:ContentPlaceHolder id="Stylesheets" runat="server">
    <link rel="Stylesheet" href="/css/master.css" type="text/css" />
</asp:ContentPlaceHolder>
<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .style2
    {
        height: 459px;
    }
    .style3
    {
        width: 100%;
        height: 100%;
    }
    .style6
    {
        height: 79px;
    }
    .style7
    {
        width: 345px;
        height: 73px;
    }
</style>
</head>
<body>
<form id="form1" runat="server">
<table>
    <tr>
        <td>
            <asp:Menu ID="Menu1" runat="server">
                <Items>
                    <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
                    <asp:MenuItem Text="About" Value="About"></asp:MenuItem>
                    <asp:MenuItem Text="Compliance" Value="Compliance">
                        <asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem>
                        <asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem>
                    </asp:MenuItem>
                    <asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem>
                    <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>
                </Items>
            </asp:Menu>
        </td>
    </tr>
    <tr>
        <td>
            <img alt="South University'"src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td>
    </tr>
    <tr>
        <td>
            <table>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            This is the footer.</td>
    </tr>
</table>
</form>
</body>
</html>

解决方法

这里有几件事.

首先,你在3个地方定义你的CSS!

在头部和外部.我建议你只选一个.我打算在外面提出建议.

我建议你在ASP表格中更新你的代码

<td>

对此:

<td>

然后更新你的CSS

.style6
    {
        height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;
    }

这将删除内联.

现在,将它从webForm的头部移开.

<%@ 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>AR ToolBox</title>
    <link rel="Stylesheet" href="css/master.css" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<table>
    <tr>
        <td>
            <asp:Menu ID="Menu1" runat="server">
                <Items>
                    <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
                    <asp:MenuItem Text="About" Value="About"></asp:MenuItem>
                    <asp:MenuItem Text="Compliance" Value="Compliance">
                        <asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem>
                        <asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem>
                    </asp:MenuItem>
                    <asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem>
                    <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>
                </Items>
            </asp:Menu>
        </td>
    </tr>
    <tr>
        <td>
            <img alt="South University'"src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td>
    </tr>
    <tr>
        <td>
            <table>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            This is the footer.</td>
    </tr>
</table>
</form>
</body>
</html>

现在,在一个名为master.css的新文件中(在你的css文件夹中)添加

ul {
list-style-type:none;
margin:0;
padding:0;
}

li {
display:inline;
padding:20px;
}
.style1
{
    width: 100%;
}
.style2
{
    height: 459px;
}
.style3
{
    width: 100%;
    height: 100%;
}
.style6
{
    height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;
}
.style7
{
    width: 345px;
    height: 73px;
}

ASP.NET MVC 4 for Visual Studio 2010 下载地址

ASP.NET MVC 4 for Visual Studio 2010 下载地址

Asp.Net MVC 4 安装包下载地址:

http://download.microsoft.com/download/2/F/6/2F63CCD8-9288-4CC8-B58C-81D109F8F5A3/AspNetMVC4Setup.exe

Asp.Net MVC 4 中文语言安装包下载地址:

http://download.microsoft.com/download/2/4/6/2464AF01-2553-4177-9D0A-D105D9A261D6/AspNetMVC4Setup_CHS.exe

Asp.Net Web Pages 2 下载地址:

http://download.microsoft.com/download/2/D/C/2DCA2ADA-AD18-40FC-9F2D-715977CB2FCC/AspNetWebPages2Setup.exe

asp.net – Visual Studio 2008,2010或2012(v11)是否写入使用多核?

asp.net – Visual Studio 2008,2010或2012(v11)是否写入使用多核?

基本上,我想知道2010和2012年的可视化工作室IDE和/或编译器是否被编写以利用多核心环境(我知道我们可以使用并行性来定位所有版本中的多核心环境,但这不是我的问题) .

我想要决定是否应该获得更高的时钟双核或者更低的时钟四核,因为我想尝试找出哪个处理器会给我最好的Visual Studio 2010或2012(v11)体验ide和后台编译器).

如果他们在一个核心中运行最重要的部分(后台编译器和其他ide任务),那么如果运行四核,那么内核将会更快地被切断,特别是如果后台编译器是最重的任务,我会想象这将是困难的在多个进程中分离,所以即使它使用多核,如果大部分处理仍然必然发生在一个核心(即VS中最重要的部分),那么仍然可能会更好地处理更高的时钟cpu环境).

我是VB程序员,他们在2010年和2012年取得了很好的表现,恭喜(除了可怕的灰度设计和大写无处不在之外),但我很想能够无缝使用VS …任何人都有想法?另外,我也不用担心解决方案的加载时间,因为我一次只编写一个项目.

谢谢.

解决方法

我认为你可能更喜欢更高级的双核.我认为VS(和大多数应用程序今天)还没有多线程的优势. VS可能有几十个线程运行,但只有一个操作的一部分真的很好地利用它们. VS实现的大部分是在STA线程上运行的C COM组件,因此UI线程在许多情况下执行大部分工作.作为VS2010的一部分,许多VS shell被重写在托管代码中的事实将有助于打破这些古代组件STA依赖关系.正如其他人所提到的,一些关键场景(如构建大型解决方案)已经充分利用了多个内核(MSBuild并行运行),所以如果这些方案占主导地位,那么更多的核心就会更好.但是对于像IDE UI使用和后台编译这样的东西,我认为其中大多数仍然是单线程的.我在工作中有一个四核盒,我很少看到VS2008使用了超过25%的cpu资源. (我没有足够认真地使用VS2010来了解哪些场景更好,尽管我知道至少有一些更好.)

asp.net – Visual Studio 2010中的HTML格式

asp.net – Visual Studio 2010中的HTML格式

每当我使用Ctrl-K在Visual Studio中重新格式化html源代码时,Ctrl-D会格式化我的源代码,如下所示:
<p>
    text</p>
<p>
    more text</p>

如何使用以下格式?

<p>
    text
</p>
<p>
    more text
</p>

我知道有选项 – >文本编辑器 – > Html – >格式化,但我找不到合适的。

谢谢,

阿德里安

编辑:我检查了特定于标签的设置,p标签的分页符设置为“打开之前,内部和结束后”。另外,小预览显示了我想要的格式。但Visual Studio仍然出错。这可能与我的系统上安装的Resharper有关吗?

解决方法

这个问题与ReSharper无关。这是通过Visual Studio源格式化程序设计的一项功能,由于您指定的格式化选项,它将尝试不更改元素的语义。

所以,你指定你希望p标签在内容中有中断,但是在p标签之后的中断会改变标签内的内容的语义,所以格式化程序最终将关闭p标签放在内容之后。要在单独的行上使用结束标签,您需要在内容结尾和结束标签之前显式添加一个空格。

从而:

<p>content</p>

将产生:

<p>
   content</p>

虽然(注意在内容和关闭p标签之间明确包含一个空格):

<p>content </p>

将产生:

<p>
   content
</p>

这是由Scott Guthrie在blog post年底部的第3段中讨论的。从附加链接部分上方的段落开始计数。

asp.net – Visual Studio 2010和Visual Studio 2012中的col,colgroup,tbody和thead throws编译错误的HTML表标记

asp.net – Visual Studio 2010和Visual Studio 2012中的col,colgroup,tbody和thead throws编译错误的HTML表标记

我有一个.NET 3.5网站,其中包含col,colgroup,tbody和thead标签.这是具有runat =“server”属性的服务器端标签.该表在Visual Studio 2010中正常工作,但在安装Visual Studio 2012和.NET 4.5之后,此标记现在无法在Visual Studio 2010和Visual Studio 2012中进行编译(我同时尝试过).以下是编译器错误被抛出:
  • The best overloaded method match for ‘System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)’
    has some invalid arguments
  • Argument ‘1’: cannot convert from ‘System.Web.UI.HtmlControls.HtmlGenericControl’ to
    ‘System.Web.UI.HtmlControls.HtmlTableRow’

以下是我正在使用的例子:

<table id="TestTable" runat="server">
    <colgroup>
        <col width="30%" />
        <col width="70%" />
    </colgroup>
    <thead>
        <tr>
            <td>Sample header 1</td>
            <td>Sample header 2</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Sample cell 1</td>
            <td>Sample cell 2</td>
        </tr>
        <tr>
            <td>Sample cell 3</td>
            <td>Sample cell 4</td>
        </tr>
    </tbody>
</table>

有没有人知道如何解决这个问题,以便我们可以让网站编译并继续工作?

解决方法

在Visual Studio 2012和.NET 4.5的安装之后,这似乎是一个未记录的破坏的网站更改.在Microsoft: http://msdn.microsoft.com/en-us/library/hh367887.aspx记录的.NET 4.5更改中,我无法找到对此的引用

在研究了这个问题之后,以下似乎是破碎表标签的可能解决方案.

>卸载Visual Studio 2012和.NET 4.5.参考:Server side HTML table with tbody not compiling in ASP.NET 4.5

我意识到这不一定是一个理想的解决方案,但是如果下面的其他解决方案都不能轻易实现,那么你可能没有别的选择.另外,只是因为这是第一个条目,这不是我推荐的主要解决方案.这只是一个选择.
>将您的网站转换为Web应用程序.在使用Web应用程序时,使用runat =“server”的表格会显示为编译文件.

执行此转换还有其他好处,例如使Web应用程序中的代码更容易编写单元测试.但是,您需要评估从网站转换为Web应用程序所涉及的工作,您需要说服您的老板和同事,您需要进行此更改.
>检查表中的服务器端代码(页面/控件后面的代码).您是否在服务器端代码中使用控件?如果没有,请删除runat =“server”.该页面然后编译很好.

<table id="TestTable">
    <colgroup>
        <col width="30%" />
        <col width="70%" />
    </colgroup>
    <thead>
        <tr>
            <td>Sample header 1</td>
            <td>Sample header 2</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Sample cell 1</td>
            <td>Sample cell 2</td>
        </tr>
        <tr>
            <td>Sample cell 3</td>
            <td>Sample cell 4</td>
        </tr>
    </tbody>
</table>

>您正在使用服务器端代码中的控件.删除col和colgroup标签,并将列样式移动到表的第一行的td或th单元格中. (列宽和样式从表的第一行继承,因此在第一个单元格上设置width =“40%”,例如,使列中的所有单元格都具有width =“40%”.)删除thead标签和将表中的所有td单元格更改为th(​​表头)单元格.删除tbody标签.

<table id="TestTable" runat="server">
    <tr>
        <th width="30%">Sample header 1</td>
        <th width="70%">Sample header 2</td>
    </tr>
    <tr>
        <td>Sample cell 1</td>
        <td>Sample cell 2</td>
    </tr>
    <tr>
        <td>Sample cell 3</td>
        <td>Sample cell 4</td>
    </tr>
</table>

>转换为使用< asp:Table>标签与< asp:TableHeaderRow>和< asp:TableRow>控制.参考:How to create thead and tbody in ASP.NET Table?

今天关于向asp.net添加样式表(使用Visual Studio 2010)asp.net style的讲解已经结束,谢谢您的阅读,如果想了解更多关于ASP.NET MVC 4 for Visual Studio 2010 下载地址、asp.net – Visual Studio 2008,2010或2012(v11)是否写入使用多核?、asp.net – Visual Studio 2010中的HTML格式、asp.net – Visual Studio 2010和Visual Studio 2012中的col,colgroup,tbody和thead throws编译错误的HTML表标记的相关知识,请在本站搜索。

本文标签: