how to passing value of session from page 2 to page 1 in asp.net? -
i have listbox , button on page 1 , when click on button, page 2 open in new tab. in page 2, i'm uploading photos folder , set session["filename"] value. want when close page 2, names of uploaded images displayed in listbox.
note: session["filename"] = names of uploaded images.
does have idea? please me.
thank you.
my upload class:
public void processrequest(httpcontext context) { if (context.request.files.count > 0) { // applications path string uploadpath = context.server.mappath(context.request.applicationpath + "/temp"); (int j = 0; j <= context.request.files.count - 1; j++) { // loop through uploaded files // current file httppostedfile uploadfile = context.request.files[j]; // if there file uploded if (uploadfile.contentlength > 0) { context.session["filename"] = context.session["filename"].tostring() + uploadfile.filename+","; uploadfile.saveas(path.combine(uploadpath, uploadfile.filename)); } } } // used fix bug in mac flash player makes // oncomplete event not fire httpcontext.current.response.write(" "); }
session server object in asp.net. means, when create session on 1 page, can use on other page, long session object wasn't removed or expired.
suppose did on page1.aspx.cs
session["filename"] = "file1";
then can access on page2.aspx.cs this:
if(session["filename"]!=null) label1.text = (string)session["filename"]
so way can access session variables on .aspx page or control-derived class.
if want access session variables in class library project than, this:
httpcontext.current.session["filename"]
also, looks have created custom httpmodule
.
be notified httpmodule must not dealing pipeline events that occur before session state being initialized.
read this know more on how , when access session variables in httpmodule
Comments
Post a Comment