【发布时间】:2020-05-17 16:45:20
【问题描述】:
我有一个网站,其中有两个页面,page1 包含 textbox 和 button1,
如果我点击了button1,它将打开包含button2的page2,
如果我点击了 button2,它会将 page2 中的值分配给 page1 中的文本框
但问题是刷新page1后值会显示在文本框中,
我的问题是如何在 page2 中单击 button2 后直接更新文本框值而不在 page1 中刷新,如下所示:
这是我的代码:
page1 aspx.cs:
<script type="text/javascript">
function openPopup() {
window.open("page2.aspx", "_blank", "WIDTH=1080,HEIGHT=790,scrollbars=no, menubar=no,resizable=yes,directories=no,location=no");
}
<asp:button text="clik" id="button1" runat="server" onclientclick="return openPopup()" xmlns:asp="#unknown" style="margin-right:30%" />
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userID"] != null)
{
txtbox.Text = HttpContext.Current.Session["userID"].ToString();
}
}
第 2 页:
protected void button2(object sender, EventArgs e)
{
Session["userID"] = row.Cells[0].Text;
}
【问题讨论】:
-
为 Label 设置 AutoPostBack true 并将 UpdateMode 属性设置为 Conditional
-
感谢 Samim Hussain 我回答了你的问题,但它没有用。