如何在ASP.NET:href和css中使用meta:resourceKey

时间:2014-04-29 16:56:14

标签: asp.net css

问题1:如果用户使用特定语言访问该页面,我想使用特定网址

<div  class="homepage-footer">
                            <img id="imgHomepageFooter" runat="server"
                                 usemap="#videomap" alt="Video" meta:resourcekey="imgHomepageFooter" />

                            <map name="videomap">
                                 <area shape="rect" id="youtubeVideo" coords="43,0,560,56" href="http://www.youtube.com/watch?v=Q2QsjVCapjs" target="_blank" alt="Youtube Video"
                                  />
                            </map>
                        </div>

我需要用特定的网址替换href,因为视频的西班牙语可能在youtube中,但是对于www.google.com中的英语,我如何根据我的元资源重定向页面


问题2:我在这个页面上使用css,但如果我把css分开,我不知道如何在meta:resourcekey中使用,所以我把它作为我页面的一部分而且我仍然是我不知道组合,如果我使用的是特定语言(即场景),我需要用特定资源替换背景图像

style type="text/css">
    div.countdown-image 
    {
        background-image: url(../images/homepage/countdown-image-ENG-2015.png);
        background-repeat: no-repeat;
        height: 150px;
    }

</style>

<!-- Countdown -->
<div id="countdown-container">
     <div class="countdown-image">
        <div id="countdown-timer" class="countdown-bottom">
        </div>
     </div>
    <input id="DeadlineDateTime" value="" runat="server" type="hidden" />
</div>

2 个答案:

答案 0 :(得分:1)

一种选择是根据用户的语言处理请求服务器端根据需要更改HTML控件的值。 @All Blond的答案遵循这种方法。

另一种选择是使用JavaScript(建议使用jQuery)在客户端执行相同操作。您可以找到相关的HTML对象(使用jQuery选择器$),并根据用户的语言替换/更新其属性。

答案 1 :(得分:0)

如果你在C#/ ASP.net那边,那么基本上你应该在你的main或onInit函数中使用

  string  userLang = HttpContext.Request.UserLanguages.ToString();
   // I would prefer do switch based on userLang  but it could be as simple as:
  if (userLang = "en-CA")
    {

      //  here you can do switch for your content anyway you want to.
      // including changing your assign CSS or images - as a string or InnnerHTML content
      // it is depend on solution you implement in your code.

    }

值“en-CA”您可以在Google上查找每种所需语言。