且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在静态方法中使用viewstate / session

更新时间:2023-12-03 23:36:28

  public   static 列表GetCompletionList( string 名称)
{

HttpContext.Current.Session [ 姓名] =姓名;
HttpContext.Current.ViewState [ 名称] =姓名;

}





和Retrive It





  public   static  List GetCompletionList()
{
String Name = HttpContext.Current.Session [ 名称]。Tostring()
string abc = HttpContext.Current.ViewState [ 名称]。Tostring()

} < / pre >


public static List<string> GetCompletionList()
{

//here we want to use viewstate /session to store a value

}

please help if any solution is it.

public static List GetCompletionList(string Name)
{

 HttpContext.Current.Session["Name"]= Name;
 HttpContext.Current.ViewState["Name"]=Name;

}



and Retrive It


public static List GetCompletionList()
{
   String Name = HttpContext.Current.Session["Name"].Tostring()
   string abc = HttpContext.Current.ViewState["Name"].Tostring()

}</pre>