gpt4 book ai didi

jquery 对话框在 asp.net 按钮上关闭

转载 作者:行者123 更新时间:2023-12-01 04:19:45 25 4
gpt4 key购买 nike

我有一个名为 A 的 aspx 页面,它正在使用母版页。页面 A 有一个链接按钮,在链接按钮上单击我想打开一个 jquery 对话框,加载名为 B 的 aspx。这对我来说效果很好。我有一个asp.net取消按钮在此处输入代码在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>

最佳答案

这样的事情对我有用......

显示对话框的页面...

<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所以我不确定是否有额外的功能可供我使用。

关于jquery 对话框在 asp.net 按钮上关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11866234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com