将值从jquery模式弹出窗口发送到父项时出现问题
本文关键字:问题 窗口 jquery 模式 | 更新日期: 2023-09-27 17:58:19
下面是我的代码
你能告诉我如何将此页面上的label1.text发送到product.aspx并更新label1.text吗???
product.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="styles/modal-window.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" language="javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript" src="scripts/modal-window.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="0"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="icrement" />
<a href="viewcart.aspx?fn=<%= Label1.Text %>" onclick="$(this).modal({width:833, height:453}).open(); return false;">show popup</a>
</div>
</form>
</body>
</html>
背后的product.aspx代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = (int.Parse(Label1.Text) + 1).ToString();
}
}
viewcart.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="decrement"
onclick="Button1_Click" />
<br />
current value:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
viewcart.aspx.cs codebehind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class viewcart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Label1.Text = Request["fn"];
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = (int.Parse(Label1.Text) - 1).ToString();
}
}
您可以在页面中添加一个asp:HiddenField控件,通过javascript设置其值,然后将其发布回您的codeehind。