开发者

problem sending value from jquery modal popup to parent

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>

p开发者_JAVA百科roduct.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();
    }
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜