页面共享数据可不可以如此 页面与页面之前共享数据是通过Session["ayonghu"];的方式 , 我感觉有点麻烦, 能不能新建一个类,里面放着静态变量,一个页面要共享的数据先存进这个类的静态变量去, 另外一个页面要取用的时候, 就直接去这个类里面抓, 我感觉这样子的方式挺简单的,为什么大家不采用. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哦那页面跟着的那个类是单独的吧不会串吧,比如下面这个代码public partial class Ifixed_Ifixeda : System.Web.UI.Page{ DataTable idt; DataTable dtfi07; Maticsoft.BLL.Ifixedclass mbi; Maticsoft.Model.AYONGHU mma; string stclassno = ""; protected void Page_Load(object sender, EventArgs e) { mma = (Maticsoft.Model.AYONGHU)Session["ayonghu"]; if (TreeView1.SelectedNode != null) { stclassno = TreeView1.SelectedNode.Value; } if (!Page.IsPostBack) { GridView1.Style.Add("table-layout", "fixed");//列宽由表格宽度和列宽度设定。 mbi = new Maticsoft.BLL.Ifixedclass(); idt = mbi.GetAllList().Tables[0]; if (idt.Rows.Count < 1) 请问一下,以下声明的变量 DataTable idt; DataTable dtfi07; Maticsoft.BLL.Ifixedclass mbi; Maticsoft.Model.AYONGHU mma; string stclassno = "";这几个变量会不会串 不会串,但是postback后,idt, mbi会是null,因为他们只在!Page.IsPostBack中初始化了。 建议看一下Page的生命周期每次PostBack发生, Ifixed_Ifixeda 这个类都会重新构建。如果想在postback之间传值,可以使用Session, viewstate, cookie等。 参考:http://www.cnblogs.com/insus/articles/1429434.htmlhttp://www.cnblogs.com/insus/articles/2032508.htmlhttp://www.cnblogs.com/insus/articles/2055531.html 嗯,我试过,虽然是重新构建,但是如果public partial class Ifixed_Ifixeda : System.Web.UI.Page{ DataTable idt; DataTable dtfi07; Maticsoft.BLL.Ifixedclass mbi; Maticsoft.Model.AYONGHU mma; string stclassno = "";被赋过值了,下次再返回的时候,值依然在哦 asp.net 开发的web项目打包成 *.exe 或者 *.msi 等等 页面跳转 web 环境下怎样批量下载文件到一个文件夹下 自定义Activex很简单滴问题. 关于视频播放 请教各位高手:如何将dropdownlist控件里的选项置空!(我的ddl控件item里包括空行) 请推荐一个.net的数据库列表显示控件 DataSet生成的xml文档如何将节点转换为属性? 新手问题,SqlCommand参数问题 如何配置重新启动web服务 文本编辑器中插入图片 有高手知道dsoframer如何实现隐藏word的菜单栏的方法?
那页面跟着的那个类是单独的吧
不会串吧,比如下面这个代码
public partial class Ifixed_Ifixeda : System.Web.UI.Page
{
DataTable idt;
DataTable dtfi07;
Maticsoft.BLL.Ifixedclass mbi;
Maticsoft.Model.AYONGHU mma;
string stclassno = "";
protected void Page_Load(object sender, EventArgs e)
{
mma = (Maticsoft.Model.AYONGHU)Session["ayonghu"];
if (TreeView1.SelectedNode != null)
{
stclassno = TreeView1.SelectedNode.Value;
}
if (!Page.IsPostBack)
{
GridView1.Style.Add("table-layout", "fixed");//列宽由表格宽度和列宽度设定。
mbi = new Maticsoft.BLL.Ifixedclass();
idt = mbi.GetAllList().Tables[0];
if (idt.Rows.Count < 1)
请问一下,以下声明的变量
DataTable idt;
DataTable dtfi07;
Maticsoft.BLL.Ifixedclass mbi;
Maticsoft.Model.AYONGHU mma;
string stclassno = "";
这几个变量会不会串
不会串,但是postback后,idt, mbi会是null,因为他们只在!Page.IsPostBack中初始化了。
如果想在postback之间传值,可以使用Session, viewstate, cookie等。
http://www.cnblogs.com/insus/articles/1429434.html
http://www.cnblogs.com/insus/articles/2032508.html
http://www.cnblogs.com/insus/articles/2055531.html
public partial class Ifixed_Ifixeda : System.Web.UI.Page
{
DataTable idt;
DataTable dtfi07;
Maticsoft.BLL.Ifixedclass mbi;
Maticsoft.Model.AYONGHU mma;
string stclassno = "";
被赋过值了,下次再返回的时候,值依然在哦