我有一个名为A的aspx页面正在使用母版页。页面A有一个链接按钮,在链接按钮单击我想打开一个jquery对话框加载与aspx称为B.这对我来说很好。我有一个asp.net取消按钮o enter code here
n页面B,在取消按钮上单击我要关闭jquery对话框并保持在页面A.在我的代码中,jquery对话框正在关闭,但它重新加载页面B在浏览器中。
母版页
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="jQueryTest.Site1" %>
<!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>Untitled Page</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<script src="../javascript/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../javascript/jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>
<link href="/css/ui-lightness/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
var mydiv = $("#dialog").dialog({
autoOpen: false,
resizable: false,
height: 700,
width: 900,
modal: true
});
mydiv.parent().appendTo(jQuery("form"));
});
function showPanel(){
var mydiv = $("#dialog")
// Load the content using AJAX
mydiv.load('/WebForm1.aspx');
// Open the dialog
mydiv.dialog('open');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
default.aspx(第A页)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MasterPageFile="~/Site1.Master"
Inherits="jQueryTest._Default" %>
<asp:Content ID="contect1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<asp:LinkButton ID="lnkChangePwd" Text="Click" OnClientClick="showPanel();return false;"
runat="server"></asp:LinkButton>
</div>
<div id="dialog" style="width: 60%; height: 45%" title="Change password">
</div>
</asp:Content>
webform1.aspx(第B页)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="jQueryTest.WebForm1" %>
<!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>Untitled Page</title>
<script src="../javascript/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../javascript/jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>
<link href="/css/ui-lightness/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready($(function () {
$("#<%=Button1.ClientID %>").bind("click", function (event) {
$("#dialog").dialog("close");
});
}));
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
this is webform 1
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
答案 0 :(得分:2)
这样的事对我有用......
显示对话框的页面......
<html>
<head>
...link js files here...
</head>
<body>
<div id="deleteDialog"></div>
</body>
</html>
页面是对话框的内容...
<html>
<head>
...link js files here...
</head>
<body>
<input type="submit" value="Close" id="uxCloseDialog" />
</body>
</html>
jquery显示并关闭对话框...
var deleteDialog;
deleteDialog = $("#deleteDialog").dialog({
autoOpen: false,
resizable: false,
width: "auto",
modal: true
});
$(".button-delete-24").click(function () {
var id = $(this).attr('data-id');
deleteDialog.empty();
deleteDialog.load("/myDialogPage.aspx"
, function () {
$("#uxCloseDialog").click(function () {
deleteDialog.dialog("close");
return false;
});
});
deleteDialog.dialog("open");
return false;
});
我确实使用jQuery UI所以我不确定是否有额外的功能可供我使用。
答案 1 :(得分:0)
尝试使用window.parent:
window.parent.jQuery("#dialog").dialog('close');