サンプル2
親画面・デザイン:SampleMain.aspx
サンプル1と同じ
親画面・コードビハインド:SampleMain.aspx.vb
Public Class SampleMain
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Button1.OnClientClick = _
"showModal('" & Me.TextBox1.ClientID & "'); return false;"
End Sub
End Class
子画面・デザイン:SampleModal.aspx
サンプル1と同じ
子画面・デザイン:SampleModal.aspx.vb
Public Class SampleModal
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Button1.OnClientClick = "closeModal('" & Me.TextBox1.ClientID & "');"
End Sub
End Class
JScript1.js
function showModal(targetID) {
var textObj = document.getElementById(targetID);
var textValue = textObj.value;
window.dialogArguments = textValue;
var returnValue = window.showModalDialog(
"SampleModal.aspx",
window,
"dialogWidth=400px;dialogHeight=300px");
if (returnValue != null) {
textObj.value = returnValue;
}
}
function init(targetID) {
var args = window.dialogArguments.dialogArguments;
var textObj = document.getElementById(targetID);
textObj.value = args;
}
function closeModal(targetID) {
var textObj = document.getElementById(targetID);
window.returnValue = textObj.value;
self.close();
}