从jquery模态弹出窗口向父级发送值时出现问题 [英] problem sending value from jquery modal popup to parent

查看:66
本文介绍了从jquery模态弹出窗口向父级发送值时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的代码

您能告诉我如何将此页面上的label1.text发送到product.aspx并更新label1.text吗?

Can you tell me how to send label1.text on this page to product.aspx and update label1.text ???

product.aspx

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.cs代码后面

product.aspx.cs code behind

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

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代码隐藏

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设置其值,然后该值将被发布回您的代码背后.

You can add an asp:HiddenField control to the page, set its value through javascript and it will be posted back to your codebehind.

这篇关于从jquery模态弹出窗口向父级发送值时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆