1

我的呼叫页面如下:

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <script type="text/javascript" src="Scripts/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.8.17.js"></script>
    <style type="text/css">
        .ui-dialog
        {
            position: fixed;
            overflow: hidden;
        }

        .ui-widget-overlay
        {
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            position: absolute;
            background: #aaaaaa;
            opacity: .3;
            filter: Alpha(Opacity=30) /*{opacityOverlay}*/;
        }
    </style>
    <script type='text/javascript'>
        function Load() {
            var sURL = "webForm4.aspx";
            $('<div id="dialogDiv"></div>').hide().load(sURL, function () {
                $(this).dialog({
                    resizable: false,
                    height: "auto",
                    width: 500,
                    position: "center",
                    modal: true,
                    showClose: false,
                    closeOnEscape: false,
                    autoOpen: true,
                    draggable: true,
                    title: "<b>Notification Policy</b>",
                    create: function (event, ui) {
                        $(".ui-dialog-titlebar-close").hide();
                    },
                    close: function () {
                        $('#dialogDiv').remove();
                    }
                });
            });
        }
    </script>
</head>
<body>
    <form id="form1">
    <input type="button" value="load" id="btn" onclick="Load();"/>
    </form>
</body>
</html>

我的动态加载页面(本例中为 webForm4.aspx)如下:

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script language="javascript" type="text/javascript">

        function bindEvent() {
            var text = $('#inittext').val();
            if (text.length < 3) {
                alert("Enter atleast 3 characters");
            }
            else {
                $('#dialogDiv').dialog('close');
            }
        }


    </script>
</head>
<body>
    <div id="content">
        <table width="100%">
            <tr>
                <td align="center">Acknowledgement (Enter Initials):
                    <input id="inittext" type="text" value="" style="width: 40px;" maxlength="3" />
                    <input id="btnContinue" type="button" value="done" style="width: 40px;" onclick="bindEvent();"/>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

我想通过单击上面代码中生成的“完成”按钮来关闭对话框,但问题是“完成”按钮单击事件永远不会被触发。谁能帮帮我吗?

webform4.aspx 中还有一个 html 文本框。如何在调用页面中获取该文本框的值?


  • PS -> 我可以更改 webForm4.aspx 的内容,因此有必要通过 webForm4.aspx 上的按钮关闭对话框

4

1 回答 1

0

尝试这个

$(this).dialog('close');改为使用$(this).dialog("close");

function bindEvent() {
        var text = $('#inittext').val();
        if (text.length < 3) {
            alert("Enter atleast 3 characters");
        }
        else {
            $(this).dialog('close');
        }
    }
于 2013-07-17T06:07:24.090 回答