【问题标题】:Looking for a smart way to add new landing pages that are 90% similar. (asp.net)寻找一种聪明的方法来添加 90% 相似的新着陆页。 (asp.net)
【发布时间】:2013-04-01 20:09:14
【问题描述】:

在一个 Asp.net 网站中,我通过创建一个从通用母版页派生的新页面来不断添加新的登录页面。这些“新”页面有 90% 是相同的(只有背景图片不同)。

我的解决方案最终包含 10 多个类似的 .aspx 页面。有没有办法更聪明地做到这一点。 (不必为每个“新”页面添加不同的 .aspx)?

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    添加一些呈现 CSS body {background-image:url(...)} 部分的代码怎么样? 这甚至不需要代码隐藏的 DLL 文件就可以解决问题:

    <% string[] backgrounds = {"b1.jpg", "b2.jpg", "b3.jpg"};
       Random rnd = new Random();
       string background = backgrounds[rnd.next(0, backgrounds.length)];
    %>
    <style type="text/css">
      body {background-image:url("<%=background%>");}
    </style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 2020-08-28
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 2014-01-09
      • 2021-03-02
      相关资源
      最近更新 更多