如何在菜单项中进行会话 [英] How to give session in menuitem

查看:70
本文介绍了如何在菜单项中进行会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在menuitem中使用会话?
如果单击登录",则会创建menuitem,它将转到下一页.
在该登录名中,我将提供用户名和密码,但不能在菜单项中使用.
任何人都可以帮助我使用会话,他们如何接受登录页面
想要通过使用会话进入下一页.

Hi,

How to use session in menuitem?
I am created menuitem if am clicking login it will goes to next page fine.
In that login the username and password I will give but it cant works in menu item.
Anyone help me with using session how they accept login page
want to go next page by using session.

推荐答案

Jasna,
我没有得到您想要的,希望这对您有帮助.
masterPage中使用的会话.希望你能有所想法.

Hi Jasna,
I am not getting Exactly what u want, hope this may help u..
session used in masterPage. Hope u may get some idea..

Note the @ Master instead of the usual @ Page declaration.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master1.master.cs" Inherits="Master2"%>



要动态更改母版页..
创建一个与第一页不同的新母版页.然后添加按钮以在母版页之间进行切换.

void LinkBut​​ton1_Click(Object sender,EventArgs e)
{
Session ["masterpage"] ="Master1.master";
Response.Redirect(Request.Url.ToString());
}

现在要动态加载母版页:

公共局部类关于:System.Web.UI.Page {
void Page_PreInit(对象发送者,EventArgs e)
{
if(Session ["masterpage"]!= null)
{
this.MasterPageFile =(String)Session ["masterpage"];
}
}
}



To change the Master Page dynamically..
Create a new Master Page different from the first. Then add buttons to change between the Master Pages.

void LinkButton1_Click(Object sender, EventArgs e)
{
Session["masterpage"] = "Master1.master";
Response.Redirect(Request.Url.ToString());
}

Now to dynamically load the Master Page:

public partial class About : System.Web.UI.Page {
void Page_PreInit(Object sender, EventArgs e)
{
if(Session["masterpage"] != null)
{
this.MasterPageFile = (String) Session["masterpage"];
}
}
}

The front end pages should look something like this:
Home.aspx
<%@ Page Language="C#" MasterPageFile="~/Master1.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Home" Title="The Home Page" %>
<%@ MasterType virtualpath="~/Master1.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<span style="color: #ffffff"></span>
<span style="color: #ffffff"></span><span style="color: #ffffff">Welcome to the website</span>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<h1>
give Comment if it helps you.</h1>
</asp:Content>





Default.aspx
<%@ Page Language="C#" MasterPageFile="~/Master1.master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" Title="About Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>
<span style="color: #ffffff">About the site</span></h1>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<h1>This is the about page</h1>
</asp:Content>





The Master Pages should look something like this:
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
<td colspan="2" bgcolor="#ccffcc" height="48" valign="top">
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="Default.aspx" Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="About.aspx" Text="About" Value="About"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Plain</asp:LinkButton>
</td>
</tr>
<tr>
<td bgcolor="#ccffcc" valign="top" width="48">
<asp:Image ID="Image1" runat="server" ImageUrl="images.jpg" Width="48px" />
</td>
<td bgcolor="#ccffcc" valign="top">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#ccffcc" height="48" valign="top">Copyright..</td>
</tr>
</table>
</div>
</form>




问候
马杜(Madhu)
madhusudhan.kammar@gmail.com




Regards
Madhu
madhusudhan.kammar@gmail.com


这篇关于如何在菜单项中进行会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆