如何创建弹出窗口以传递在主Aspx窗口中弹出的选项 [英] How Do I Create Popup Window To Pass Option Selected In Pop Up In Main Aspx Window

查看:76
本文介绍了如何创建弹出窗口以传递在主Aspx窗口中弹出的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击按钮时创建弹出窗口,允许用户在弹出窗口中选择任何选项,然后选择的选项值必须发送回aspx页面..我搜索并发现ajax可以这样做..无论如何我只能使用asp.net c#代码..如果是这样,plz提供示例代码或链接。

提前谢谢

i wanted to create pop up window on click of a button to allow user to select any option in pop up and then the option value selected must be send back to aspx page.. i searched and found out that ajax can do so.. is there anyway i can do using asp.net c# code only.. if so plz provide a sample code or link.
thank you in advance

推荐答案

试试这个



Try this

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript">
        var OpenPopup = function () {
            var value = window.showModalDialog("POPUPPage.aspx", 'popup', "dialogHeight:200; dialogWidth:200;  center:yes;toolbar: false;status: 0;scroll:0;unadorned:0;help:no");
            document.getElementById('txtValues').value = value;
        }
    </script>
</head>
<body>
    <form id="frm" runat="server">
    <asp:TextBox ID="txtValues" runat="server"></asp:TextBox>
    <asp:Button ID="btnPopUP" OnClientClick="OpenPopup(); return false;" runat="server"

        Text="LookUP" />
    </form>
</body>
</html>





POPUP页面:





POPUP Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="POPUPPage.aspx.cs" Inherits="POC.POPUPPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var closepopup = function () {

            var temp = '';
            var radiolist = document.getElementById('<%= RadioButtonList1.ClientID %>');
            var radio = radiolist.getElementsByTagName("input");

            for (var x = 0; x < radio.length; x++) {
                if (radio[x].type === "radio" && radio[x].checked) {
                    temp = radio[x].value;
                    break;
                }
            }

            window.returnValue = temp;
            window.close()
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
            <asp:ListItem Text="One" />
            <asp:ListItem Text="two" />
            <asp:ListItem Text="three" />
            <asp:ListItem Text="four" />
            <asp:ListItem Text="five" />
        </asp:RadioButtonList>
        <asp:Button ID="btnClose" runat="server" OnClientClick="closepopup(); return false;"

            Text="Select & Close" />
    </div>
    </form>
</body>
</html>


如果您不想使用 Ajax ,然后去 jQuery Dialog [ ^ ]。



它的重量非常轻且有用。
If you don't want to use Ajax, then go for jQuery Dialog[^].

It is very light in weight and useful.


这篇关于如何创建弹出窗口以传递在主Aspx窗口中弹出的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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