我的调用页面如下所示:
<%@ 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文本框。 如何在调用页面中获取该文本框的值?
答案 0 :(得分: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');
}
}