Created
March 17, 2017 01:14
-
-
Save peyangu/73d130c33546258fa51806a82044abc3 to your computer and use it in GitHub Desktop.
showModalDialogの呼び出し時に親画面のスクロール位置が初期位置に戻ってしまうのを防ぐ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Button1_Click(object sender, EventArgs e) | |
{ | |
// 何かしらの処理 | |
StringBuilder script = new StringBuilder(); | |
// 重要なのは↓ | |
script.Append("<script language='JavaScript'> if (WebForm_RestoreScrollPosition) WebForm_RestoreScrollPosition();"); | |
script.Append("window.showModalDialog('hoge.aspx', window, 'dialogWidth: 300px; dialogHeight: 200px; center; scroll=0; status=0,location=0');</script>"); | |
ClientScriptManager csMgr = Page.ClientScript; | |
csMgr.RegisterStartupScript(this.GetType(), "DoOpenScript", script.ToString(), false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment