画像ファイルをアップロードするための .aspx ページを 1 つ作成しました。
ページ 1 - そこから、js で window.open (ダイアログ ボックスのような小さいサイズ) を使用して Page2.aspx を開きます。
次に、ページ 2 の Javascript で、WindowRefresh() 関数を使用してページ 1 を更新し、ページ 2 を閉じます (ファイルのアップロードが完了したら)。
これが、「window.opener.location.href」を使用して親ページ (ページ 1) を参照した理由です。
ページ 2 では、親ウィンドウを更新する Windowrefresh() 関数の下にあり、アップロード ダイアログ ウィンドウを閉じます。
function Windowrefresh() {
if (window.navigator.appName == "Netscape") {
window.opener.location.href = window.opener.location.href;
window.opener.location.reload(true);
self.close();
}
else if (window.navigator.appName == "Microsoft Internet Explorer") {
window.opener.location.href = window.opener.location.href;
window.opener.location.reload(true);
window.close();
}
}
ここで、1 つのセッション変数に何らかの値がある場合に、ページ 2 のコード ビハインドからこの関数を呼び出したいと思います。
以下のものを試しました。
ClientScript.RegisterStartupScript(this.GetType(), "key", "Windowrefresh();", true);
と、
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "Windowrefresh()", true);
しかし、ページ 1 を更新することも、ページ 2 を閉じることもありません。
これで何が悪いのかわかりません。