說明:點選母視窗上的TextBox後,彈出一日曆子視窗,點選日期後回傳至母視窗TextBox上。
作法:
Parent.aspx
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function SetDate(ClientID)
{
var Url = '../modaldialog/SetDate.aspx?DialogClientID=' + ClientID;
window.open(Url, 'Calendar', 'width=335, height=170');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDate" runat="server" onclick="SetDate(this.id)"></asp:TextBox>
</form>
</body>
Son.aspx
protected void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
if (Request.QueryString["DialogClientID"] != null)
{
string strClientID = Request["DialogClientID"].ToString().Trim();
StringBuilder sbJScript = new StringBuilder();
sbJScript.Append("window.opener.document.getElementById('" + strClientID + "').value = '" + this.Calendar1.SelectedDate.ToString("yyyy/MM/dd") + "';");
sbJScript.Append("window.close();");
ClientScript.RegisterStartupScript(this.GetType(), "ReturnValue", sbJScript.ToString(), true);
}
}
參考資料:
http://social.msdn.microsoft.com/Forums/zh-TW/b415ff68-2dcc-4e1c-b202-e41b4e29f8a9/a-popup-b-a-
沒有留言:
張貼留言