【问题标题】:Is there a solution to add css template in existing webform which is now having template?是否有解决方案可以在现在具有模板的现有 web 表单中添加 css 模板?
【发布时间】:2013-02-28 09:03:43
【问题描述】:

有没有办法为没有添加 CSS 模板的现有 web 表单添加 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>

【问题讨论】:

    标签: c# asp.net css templates


    【解决方案1】:

    您可以在&lt;head runat="server"&gt; 部分添加

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

    【讨论】:

    • 我已经将所有这些 css 标记链接从站点主站点复制到没有模板的 webform2 我忘记在 webform2 中添加母版页但现在我该怎么做@shekhar 但感谢之前完成了这个但所有我的 webform2 设计内容被破坏了
    • 然后它说找不到内容,如果我删除了  
    •   这个呢?如果我删除了,那么错误就很清楚了,但是说找不到内容,如果我添加了,那么错误发生了怎么办?
    • 你到底想要什么?想要在现有页面上应用母版页?
    • 嘿shekhar,但我的网络表单内容不见了,如果添加母版页的内容,则会出错
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    相关资源
    最近更新 更多