How to pass a hidden field from one page to another?

前端 未结 5 2005
别那么骄傲
别那么骄傲 2021-01-28 01:23

I have a .Net class library. I want to pass a hidden variable from once code behind page and fetch it in another code behind page. PLease note I dont have any design page(aspx p

5条回答
  •  攒了一身酷
    2021-01-28 01:57

    You can use Session or HttpContext.Current.Items .If you value is a temporary variable I suggest using HttpContext.Current.Item instead of session since it will be gone as soon as current HttpContext is gone but items that are stored in Session won't be cleared until session is expired.

    Session["var"]=value;
    
    var value=Session["var"];
    
    HttpContext.Current.Items["var"]=value;
    
    var value=HttpContext.Current.Items;
    

提交回复
热议问题