【问题标题】:Standard header page across all internal sites所有内部网站的标准标题页
【发布时间】:2015-01-08 17:13:57
【问题描述】:

我们有很多内部网站可以使用一些标准化。出于几个原因,我希望向所有网站添加一个通用横幅页面 -

  • 外观一致
  • 轻松更新横幅徽标
  • 显示服务器维护公告等公告

我们有 IIS 和 ASP.net。我确实在我将横幅页面作为位于现有网站顶部的独立 html 页面的地方进行了工作,但我确信有更好的方法。我不想走母版页的方式,主要是因为它会更改页面的控件 ID,而且我们有几个使用 JQuery 和 Javascript 的网站会在控件 ID 更改时中断。

【问题讨论】:

  • 小心标签,你有一个 c 标签。
  • Anusha,如果您觉得正确,请善待并接受我的以下回答。

标签: asp.net iis banner web-standards


【解决方案1】:

您可以如下创建一个 javascript 函数并更新所有页面的正文标记以调用该函数,例如 onload="onAllPageLoad()"

function onAllPageLoad() {
 $('body').prepend('My common banner HTML elements');
}

这会将您的横幅html元素作为body标签中的第一个元素。

【讨论】:

  • 感谢您的评论,但这不是我想要的,我发布了我想出的答案。
【解决方案2】:

我能够通过使用 Jquery 的 get 函数将横幅页面与网站页面拼接起来来破解一个解决方案。需要注意的是,每个内部网站页面都必须带有 get 功能以获得统一的外观。由于我们的大多数网站都是单页应用程序,因此目前可以使用。我有一些特定于网站的信息要添加到横幅中,并且横幅页面的任何更新都会反映在网站页面上。

这是我想出的代码 -

Banner.htm 页面:

<table width="100%" border="0">
        <tr>
            <td style="width: 30%" align="left">
                <a href="http://SiteHomePage">
                   <img alt="Site Home" border="0" src="http://SiteHomePage/img/SiteHomePagelogo.png"
                        width="119px" height="67px" /></a>
                   
            </td>
            <td style="width: 70%">
                <table width="100%">
                    <tr>
                        <td  style="text-align:left;">
                            <div id="SiteName" style="font-weight: bold; font-size: 30px;">
                            </div>
                        </td>
                        <td>
                            <div id="ExtraInfo" style="float: right; font-weight: bold; font-size: 15px;">
                            </div>
                        </td>                        
                    </tr>
                </table>
            </td>
        </tr>       
    </table>

Default.aspx 页面:

<html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
    <%--Script to add banner page starts here--%>
    <script runat="server">
      
      <%--Fetch site specific info from the site web.config --%>

      string SiteInfo =
        ConfigurationManager.AppSettings["SiteInfo"];
      string PageTitle =
        ConfigurationManager.AppSettings["PageTitle"];

      <%--BannerURL value is Banner.htm--%> 
      string BannerURL =
        ConfigurationManager.AppSettings["BannerURL"];
     </script>

    <script src="//code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      var extraInfo = '<%= SiteInfo %>';
      var title = '<%= PageTitle %>';
      var BannerURL = '<%= BannerURL %>';

      $(document).ready(function() {
        $.get(BannerURL, function(data) {
          $("#Banner").html(data);
          $("#SiteName").html(title);
          document.title = ":: " + title + " ::";
          $("#ExtraInfo").html(extraInfo);
        });
      });
    </script>
    <%--Script to add banner page ends here--%>
    </head>

   <body>
   <form id="form1" runat="server">
    <div id="Banner">

    </div>

    < %--Add site code here--%>


     </form>
     </body>

     </html>

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多