problem sending value from jquery modal popup to parent

十年热恋 提交于 2019-12-25 00:52:04

问题


below is my code

Can you tell me how to send label1.text on this page to product.aspx and update 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.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

<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();
    }
}

回答1:


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



来源:https://stackoverflow.com/questions/6237009/problem-sending-value-from-jquery-modal-popup-to-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!