【问题标题】:Implementing Session执行会议
【发布时间】:2011-04-01 16:07:03
【问题描述】:

我有一段代码可以加载法语或英语文本和 2 个允许在它们之间切换的链接按钮。

<%              
if publierFR = 0 Then
    if publierEN = 0 Then
        response.write("<p>Aucun texte n'est disponible.</p>")
    else
        response.write(texteEN)
    end if
else
    if publierEN = 1 or Session("lang") = "EN" then
%>          
        <asp:LinkButton OnClick="makeVisibleEN" ID="makeEN" runat="server" visible="false">Version Française</asp:LinkButton>           
        <asp:LinkButton OnClick ="makeVisibleFR" ID="makeFR" runat="server" visible="true">Version Anglaise</asp:LinkButton>
<%
        if makeEN.visible = true then
            response.write(texteEN)
        else
            response.write(texteFR)
        end if
    elseif publierEN = 0 or Session("lang") = "FR" then
        Response.write(texteFR)
    end if
end if
%>

如果英语和法语都存在并且会话存在于 EN 或 FR 中,那么显示链接按钮和文本的有效方式是什么。

我曾想过使用面板来隐藏按钮或文本,但主要问题是让页面刷新来设置 Session 变量。 Response.redirect(URL) 刷新页面我想我找不到比Response.write 更好的方式来显示文本,从那时起我需要大量的标签。

【问题讨论】:

    标签: asp.net vb.net


    【解决方案1】:

    您应该使用 .NET(和 ASP.NET)本机本地化功能,并且只需更改正在执行页面的线程的文化。如果需要,您仍然可以将该文化存储在 Session 中(或其他地方:在数据库中、在 cookie 中、在呈现的页面中、在视图状态中等)。

    这里有一些关于 ASP.NET 本地化的链接:

    Best practices for ASP.NET web application localization

    Asp.net multilingual web application - localization

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-19
      • 1970-01-01
      相关资源
      最近更新 更多