c# - 是否有在现有模板中添加 css 模板的解决方案?

标签 c# asp.net css templates

有没有办法为没有添加 CSS 模板的现有网络表单添加 CSS 模板?

我的代码在下面列出,任何关于如何为站点管理员中已经存在的表单添加 CSS 模板的指导将不胜感激:

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Linkchecker.WebForm2"
    ValidateRequest="false" EnableViewState="false" EnableViewStateMac="false" EnableSessionState="True"
    EnableEventValidation="false" ViewStateEncryptionMode="Never" %>

<!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>

    <script type="text/javascript">
        function finda() {
            var a = document.getElementsByTagName("a");
            var b = document.getElementById("TextBox1");
            b.value = "";


                        for (var i = 0; i < a.length; i++) {
                            a[i] = a.length.value;


                            if (a[i] == null) {
                                alert("Their is no links");
                            }   
                            else {
                                b.value = b.value + "\r\n\n" + a[i]  ;
                            }

                        }

                        //            window.open("http://www.fillsim.com");
                        window.close();
                     //   window.open("WebForm3.aspx?req=" + b.value);


        }
    </script>
     <script>
         var howLong = 6000;
         t = null;
         function closeMe() {
             t = setTimeout("self.close()", howLong);
         }
   </script>
      <script type = "text/javascript">


     var defaultText = "http://www.example.com";
           function waterMarkText(txt, evt) {
               if (txt.value.length == 0 && evt.type == "blur") {
                   txt.style.color = "red";
                   txt.value = defaultText;
               }
               if (txt.value == defaultText && evt.type == "focus") {
                   txt.style.color = "green";
                   txt.value = "";
               }
       }
</script>

</head>
<body >

    <form id="form1" runat="server">
    Enter the URL:<br />
    <asp:TextBox ID="urltxt" runat="server" Width="402px" Text="http://www.example.com" ForeColor="Gray" onblur = "waterMarkText(this, event);" onfocus = "waterMarkText(this, event);"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="btnRender" runat="server" Text="Page Render" OnClick="btnRender_Click" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="btn_submit" runat="server" Text="Submit" OnClientClick="javascript:finda();" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btn_createlink" runat="server"
        Text="Create link" OnClick="btn_createlink_Click" />
    &nbsp;&nbsp;&nbsp;
    <br />
    <br />
    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="373px" Width="410px"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="TextBox2" runat="server" Height="371px" TextMode="MultiLine" Width="409px"></asp:TextBox>
    &nbsp;<div class="ab" id="div" runat="server">
        <br />
&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Clear" 
            Width="71px" />
    </div>
    </form>


</body>
</html>

最佳答案

您可以在您的 <head runat="server"> 中添加节

<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
<style type="text/css">
   .product-bottom-container 
   {
        width: 100%;
        overflow: hidden;
        height: 10px;
        border-top: 1px solid #C41212;            
        background-color: #ECECEC;

   }
</script>

合并它

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Linkchecker.WebForm2"
    ValidateRequest="false" EnableViewState="false" EnableViewStateMac="false" EnableSessionState="True"
    EnableEventValidation="false" ViewStateEncryptionMode="Never" %>

<!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="Styles/Site.css" rel="stylesheet" type="text/css" />

编辑1

这是一个如何在现有页面中添加母版页的链接
How to assign a master page to a existing .aspx page?

关于c# - 是否有在现有模板中添加 css 模板的解决方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15131388/

相关文章:

c# - 混淆 if(something){} 和 if(something == true){}

c# - i==0 和 0==i 有区别吗?

html - 无法将 CSS 样式应用于 asp 标签

ASP.NET session Cookie - 指定基域

html - 主 Div 背景颜色未出现在子 Div 上

html - 有人能告诉我为什么下面的 CSS 不会将段落和相关的 div 居中吗?

c# - 使用数组读取 JSON 文件

c# - 在 DDD 中管理持久性

asp.net - ConfigurationManager ConnectionStrings 从哪里获取它的值?

javascript - 如何仅针对 Vanilla Javascript 中的当前悬停元素