如何使用session在另一个页面中调用obj值 [英] How to call obj value in another page using session

查看:35
本文介绍了如何使用session在另一个页面中调用obj值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学生obj =新学生();

obj.Name =ABC;

obj.Age = 20;

obj .TotMarks = 500;



会话[详情] = obj;



现在我想要呼叫姓名,年龄,标记在另一页。

如何拨打电话...请帮助我。

提前致谢

解决方案

学生obj = 学生(); 
obj.Name = ABC;
obj.Age = 20 ;
obj.TotMarks = 500 ;

会话[ 详细信息] = obj;





如果你想在其他页面中使用姓名和年龄,你必须将obj强制转换为学生班



喜欢这个



  string  name =(学生)obj.Name; 
int age =(Student)obj.Age;


问题是关于使用会话状态值的本质。请参阅: http://msdn.microsoft.com/en-us /library/87069683%28v=vs.85%29.aspx [ ^ ]。



你甚至不知道甚至是概述中的代码示例回答你的问题: http://msdn.microsoft.com/en- us / library / ms178581%28v = vs.85%29.aspx [ ^ ]?



-SA

Student obj=new Student();
obj.Name="ABC";
obj.Age=20;
obj.TotMarks=500;

Session["Details"]=obj;

Now i want to call Name, Age, Marks in another page.
How to call ... Please help me.
Thanks in advance

解决方案

Student obj=new Student();
obj.Name="ABC";
obj.Age=20;
obj.TotMarks=500;
 
Session["Details"]=obj;



If you want to use Name and age in other page, You have to typecast the obj to Student class

like this

string name = (Student)obj.Name;
int age = (Student)obj.Age;


The question is about the very essence of using session state values. Please see: http://msdn.microsoft.com/en-us/library/87069683%28v=vs.85%29.aspx[^].

Don''t you see that even the code sample in Overview answers your question: http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.85%29.aspx[^]?

—SA


这篇关于如何使用session在另一个页面中调用obj值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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