网上有个一BBS文章管理,BbsListControl用户自定义控件,里面包含有以下定义:
public const string ArgumentString = "BbsListControl_New.ArgumentString";
BbsListControlArgs_New arguments
{
get
{
if(Session[ArgumentString]==null)
{
Session[ArgumentString] = new BbsListControlArgs_New();
}
return (BbsListControlArgs_New)Session[ArgumentString];
}
set
{
Session[ArgumentString]=value;
}
}public class BbsListControlArgs
{
public string ID="7ec7b6da-ff00-45a7-acc8-1e4aab9a7ad2";
public bool DishplayMoreButton=true;
public bool AllowPaging=true;
public int PageSize=10;
public bool ShowContent=true;
public bool AllowAddNew=true;
public bool HasBorder=false;
public bool IsChildList=false;
public bool ShowBullet=true;
public bool ShowPageNavigator=false;
public bool ShowDate=false;
public bool ShowEditButtons = false;
public bool ShowOnlyRectanly = false;
}
这两个主要通过Session保存进入BBS一些属性设置,然后设置DataGrid属性和查询数据库(代码没写出)比如公告信息模块,只需要这样用就OK,其他模块也一样。
ETAX.Web.Bbs.BbsListControlArgs args = new ETAX.Web.Bbs.BbsListControlArgs();
args.AllowAddNew = false;
args.AllowPaging = true;
args.PageSize = 5;
args.DishplayMoreButton = true;
args.HasBorder = false;
args.GroupID = ItemGuid.公告信息;
args.ShowOnlyRectanly = true;
args.IsChildList = false;
args.ShowContent = false;
args.ShowDate = false;
args.ShowEditButtons = false;
args.ShowBullet = false;
Session[ETAX.Web.Bbs.BbsListControl.ArgumentString] = args;
我想问的是,如果不用Session来保存,还有什么办法更好??
public const string ArgumentString = "BbsListControl_New.ArgumentString";
BbsListControlArgs_New arguments
{
get
{
if(Session[ArgumentString]==null)
{
Session[ArgumentString] = new BbsListControlArgs_New();
}
return (BbsListControlArgs_New)Session[ArgumentString];
}
set
{
Session[ArgumentString]=value;
}
}public class BbsListControlArgs
{
public string ID="7ec7b6da-ff00-45a7-acc8-1e4aab9a7ad2";
public bool DishplayMoreButton=true;
public bool AllowPaging=true;
public int PageSize=10;
public bool ShowContent=true;
public bool AllowAddNew=true;
public bool HasBorder=false;
public bool IsChildList=false;
public bool ShowBullet=true;
public bool ShowPageNavigator=false;
public bool ShowDate=false;
public bool ShowEditButtons = false;
public bool ShowOnlyRectanly = false;
}
这两个主要通过Session保存进入BBS一些属性设置,然后设置DataGrid属性和查询数据库(代码没写出)比如公告信息模块,只需要这样用就OK,其他模块也一样。
ETAX.Web.Bbs.BbsListControlArgs args = new ETAX.Web.Bbs.BbsListControlArgs();
args.AllowAddNew = false;
args.AllowPaging = true;
args.PageSize = 5;
args.DishplayMoreButton = true;
args.HasBorder = false;
args.GroupID = ItemGuid.公告信息;
args.ShowOnlyRectanly = true;
args.IsChildList = false;
args.ShowContent = false;
args.ShowDate = false;
args.ShowEditButtons = false;
args.ShowBullet = false;
Session[ETAX.Web.Bbs.BbsListControl.ArgumentString] = args;
我想问的是,如果不用Session来保存,还有什么办法更好??
解决方案 »
- 如果管理员登陆后台,如何更改某一个用户的profile的数据?
- 类型无法转换,功能仍然可以实现,无法解释...???
- div做的tab之间切换的问题????
- asp.net中如何把添加的信息自动存到数据库中?
- 新手:用DataGrid显示数据的问题!
- 关于javascript调用.exe文件
- 关于Ajax1.0 UpdatePanel控件
- 这都要出错,崩溃了,help me
- 求一SQL语句:如何将字段Field值(字段类型为字符型)中含有8的记录获取到? 必须等于8,而不能将18、80等数据取出来。该字段存储数据格
- ASP.NET运行环境要求是什么,通常用哪种语言来写??
- 关于在在服务器端创建目录问题
- 类似ide的功能,请给我思路,全部家产都给你了,在线等待。
aa.aspx?text=aaa
你要传一个庞大的对象,用session是个不错的选择了
//////////////////////////////////////////////
firstpage.aspx
//////////////////////////////////////////////
<%@ Page Language="C#" Inherits="FirstPageClass" %><html>
<head></head><body> <form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br/>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br/>
<asp:Button
id="Button1"
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form></body></html>
//////////////////////////////////////////////////
firstpage.aspx.cs
//////////////////////////////////////////////
using System;public class FirstPageClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox first;
protected System.Web.UI.WebControls.TextBox last;
protected System.Web.UI.WebControls.Button Button1; public string FirstName
{
get
{
return first.Text;
}
} public string LastName
{
get
{
return last.Text;
}
} void ButtonClicked(object sender, EventArgs e)
{
Server.Transfer("secondpage.aspx");
}
}//////////////////////////////////////////////////
secondpage.aspx
//////////////////////////////////////////////////
<%@ Page Language="C#" Inherits="SecondPageClass" %>
<%@ Reference Page="firstpage.aspx" %><html><head></head> <body> <form runat="server"> Hello <%=fp.FirstName%> <%=fp.LastName%> </form></body></html>
//////////////////////////////////////////////////
secondpage.aspx.cs
//////////////////////////////////////////////////
using System;public class SecondPageClass : System.Web.UI.Page
{ protected System.Web.UI.WebControls.Label DisplayLabel;
public FirstPageClass fp; void Page_Load()
{
if (!IsPostBack)
{
fp = (FirstPageClass) Context.Handler;
}
}}
应该充分利用C#的特点,写出来的才算真正的.net
程序执行顺序应该是执行首页PageLoad(),然后执行公告信息版用户控件的代码,即那些设置属性,然后在执行BbsListControl.ascx,原来用Session保存,但发现执行的时候用户多的,会有点慢。ViewState只能够保存本页的东西,跨页不行。
至于Cache,服务器是否为每个用户分配一空间???如果同一空间可能会用户数据有冲突??
我的网站有三层开发,并没有使用存储过程。