我正在使用JavaScript将一个值从对话框传递到asp父页面的简单示例/快速修复 - 如果java脚本是最好的选项!
我已经多次尝试这样做,但到目前为止每次努力都失败了。
lblVarSelectedDate.Text是我想回发到父页面的值,显示为lblVarChildSelectedDate值。
以下是Register.aspx页面(PARENT)的一部分
<table>
<tr>
<td colspan="5" align="center"><asp:Label ID="lblDate" runat="server" Text="Selected Date: "></asp:Label><asp:Label ID="lblVarChildSelectedDate" runat="server" ></asp:Label></td>
<td colspan="1" align="center"><asp:Button ID="btnSelectDate" runat="server" Text="Date" /> </td>
</tr
<tr>
<td><asp:Button ID="btOK" runat="server" Text="Ok" /> </td>
</tr>
</table>
这是寄存器后面的VB.aspx ...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Sub btnSelectDate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSelectDate.Click
Dim Window As String
Window = " window.open('About.aspx', 'MsgWindow', 'width=500, height=500');"
ClientScript.RegisterClientScriptBlock(Me.GetType, "date", Window, true)
End Sub
Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btOK.Click
End Sub
现在她是我的子页面selectdate.aspx ..
<table>
<tr>
<td colspan="6"><asp:Calendar ID="calSelecter" runat="server" OnSelectionChanged="SelectionChange"></asp:Calendar></td>
</tr>
<tr>
<td colspan="6" align="center"><asp:Label ID="lblConsSelectedDate" runat="server" Text="Selected Date: "></asp:Label><asp:Label ID="lblVarSelectedDate" runat="server" ></asp:Label></td>
</tr
<tr>
<td><asp:Button ID="btOK" runat="server" Text="Ok" /> </td>
</tr>
</table>
她是儿童页面背后的vb。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
calSelecter.SelectedDate = Date.Today
lblVarSelectedDate.Text = Date.Today
End Sub
Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btOK.Click
' .... on click post back to parent page lblVarSelectedDate.Text
End Sub
Sub SelectionChange(ByVal sender As Object, ByVal e As EventArgs)
lblVarSelectedDate.Text = calSelecter.SelectedDate
End Sub
非常感谢
答案 0 :(得分:0)
一种方法如下: