我在頁面1上有一個列表框和按鈕,當我點擊按鈕時,頁面2將在一個新選項卡中打開。在第2頁中,我將照片上傳到文件夾並設置會話[「FileName」]值。我想關閉頁面2時,上傳的圖像的名稱顯示在列表框中。如何在asp.net中將會話的值從第2頁傳遞給第1頁?
注意:session [「FileName」] =上傳圖像的名稱。
有沒有人有想法?請幫幫我。
謝謝。
我上傳類:
public void ProcessRequest(HttpContext context)
{
if (context.Request.Files.Count > 0)
{
// get the applications path
string uploadPath = context.Server.MapPath(context.Request.ApplicationPath + "/Temp");
for (int j = 0; j <= context.Request.Files.Count - 1; j++)
{
// loop through all the uploaded files
// get the current file
HttpPostedFile uploadFile = context.Request.Files[j];
// if there was a file uploded
if (uploadFile.ContentLength > 0)
{
context.Session["FileName"] = context.Session["FileName"].ToString() + uploadFile.FileName+",";
uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
}
}
}
// Used as a fix for a bug in mac flash player that makes the
// onComplete event not fire
HttpContext.Current.Response.Write(" ");
}
簡單的更新第1頁,第2頁接近後 - 還是不要打開第二頁,並從一個頁面做的一切。 – Aristos 2013-04-20 09:40:06
如果這是可能的,我希望它會通過Javascript完成。我不認爲它是一個asp.net特定的問題。也許這可能會指向你在正確的方向http://stackoverflow.com/questions/5139657/closing-child-pop-up-and-refreshing-parent-page – 2013-04-20 09:42:02
謝謝TwentyGotoTen。這非常有幫助。 – 2013-04-20 10:18:03