在我的 Production.aspx Web 表单中,我有以下代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Index.Master" AutoEventWireup="true" CodeBehind="Production.aspx.cs" Inherits="WebPortal.Production" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h3>PRODUCTION SITE</h3>
<img src="" alt="Production Logo" height="350" width="350" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<asp:Login ID="Login1" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" Height="187px" Width="235px">
<TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
</asp:Login>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
</asp:Content>
在我的 Production.aspx.cs Web 表单中,我有以下代码:
namespace WebPortal
{
public partial class Production : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
var GetSession = Session["Counter"];
if (Convert.ToInt32(GetSession) == 1)
{
// Show Content 1
}
else if (Convert.ToInt32(GetSession) == 2)
{
// Show Content 2
}
else
{
// Show Content 3
}
}
catch (Exception ex)
{
// MessageBox.show(ex.message.tostring());
}
}
}
}
我如何尝试根据会话值隐藏内容,例如当用户尝试通过其帐户登录时,并根据其访问级别,他得到一个 1,触发 if 语句,然后根据其值显示要显示的内容..