日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

asp.net模态窗口返回值

發布時間:2023/11/30 asp.net 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 asp.net模态窗口返回值 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  個人感覺模態窗口在做網站的時候,使用到的比較少,前段時間在做項目時要實現以模態窗口傳值和接收返回值,

模態窗口傳值實現比較簡單,但是做好后發現在Chrome瀏覽器中接收不到返回值,修改好Chrome瀏覽器的問題后

大概過了有兩個星期又發現在IE6下會報錯,最終在網上搜索解決辦法才修改好

代碼:

A為父頁面,B為子頁面

A頁面代碼:

//打開選擇客戶的模態窗口function sc(tag) {var recdata = false;var strDialogFeatures = "status=no;center=yes;help=no;dialogWidth=700px;dialogHeight=600px;scroll=yes;resize=no";recdata = showModalDialog("Modal_List_forother.aspx?id=" + tag + "", "newwindow", strDialogFeatures);
       //此處的if判斷語句必須需要,如果直接用recdata=window.returnValue賦值的話在IE6下會無法獲取到返回值,至于原因,我也不清楚I'M SORRY o(╯□╰)o
if (recdata == undefined) {recdata = window.returnValue;}if (recdata != undefined) {//刷新父窗口 此處可以不刷新 因項目功能需要 所以在此處做了刷新操作var url = window.location.href.toString();
         //此處省略對變量url的部分操作,根據需要實現的功能不同代碼也會不一樣window.location.href
= url;}}

B頁面代碼:

首先在要想在IE6下也能接收模態窗口返回值 先要在B頁面的head部分添加代碼<base target="_self" />

如下:

<head runat="server"><title>子窗口</title><link href="Styles/basic.css" rel="stylesheet" type="text/css" /><base target="_self" /> </head>

要想從后臺返回值到父頁面去,我們還需在頁面的cs文件中添加如下代碼:

string strscripts = "";strscripts = strscripts + "<script type=\"text/javascript\">";
       //這是原先的返回值代碼,也是正確的,只是嫌太長不想用
//strscripts = strscripts + " if(window.opener!=undefined){ window.opener.returnValue = '" + name + "'; }else{window.returnValue = '" + name//+ "';} window.close();</script>";strscripts = strscripts + " window.returnValue = '" + name+ "';window.close();</script>";ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script type=\"text/javascript\"> window.returnValue = '" + name + "';window.close();</script>");

?

?

轉載于:https://www.cnblogs.com/xuxw/p/3416455.html

總結

以上是生活随笔為你收集整理的asp.net模态窗口返回值的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。