我有一个asp.net应用程序,在右上角,我想显示“联系我们”链接。单击此链接按钮时,应打开一个弹出窗口,并且休息区应呈灰色显示。
现在,要在应用程序的所有页面中显示Contact US,必须将其添加到母版页。下面是我正在尝试修改的母版页代码,但不知何故对话框无法打开。当然,这是由于div的位置。有谁能给我引路吗?
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="mstMainPage.master.cs"
Inherits="TestProj.Master.mstMainPage" %>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../CSS/StyleSheet.css" rel="stylesheet" type="text/css" />
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<style>
.ui-widget-header,.ui-state-default, ui-button{
background:#b9cd6d;
border: 1px solid #b9cd6d;
color: #FFFFFF;
font-weight: bold;
}
</style>
<script language="javascript" type="text/javascript">
$(function(){
$("#btnContactUs").click(function() {
($("#dialog-5").dialog("isOpen") == false) ? $("#dialog-5").dialog("open") : $("#dialog-5").dialog("close") ;
});
$("#dialog-5").dialog({autoOpen: false});
});
function CloseWindow() {
window.close();
}
</script>
</head>
<body style="margin-top: -5px; margin-left: -5px; margin-right: 0px; border-color: #79ACCA; border-width">
<form id="form1" runat="server">
<div>
<!-- Main Panel -->
<asp:Panel ID="Panel2" runat="server" Width="100%" Style="margin-left: 0px">
<asp:Table runat="server" ID="tab1" Width="100%">
<asp:TableRow>
<asp:TableCell Height="28px" Width="100%" BackColor="#79ACCA" HorizontalAlign="Right">
<asp:Button ID="btnContactUs" runat="server" Text="Contact Us" >
</asp:Button>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
<asp:Panel runat="server" CssClass="ContentMargin">
<asp:ContentPlaceHolder ID="cphMSTMainPage" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
<div id="dialog-5" title="Dialog Title!">
Click on the Toggle button to open and close this dialog box.
</div>
</div>
</form>
</body>
</html>发布于 2015-11-30 13:56:13
如果页面重载导致此问题,请尝试此方法。
Aspx标记:
<asp:Button ID="btnContactUs" runat="server" Text="Contact Us" CssClass="LogOff" OnClientClick="OpenDialog(this);return false;"></asp:Button>Javascript:
function OpenDialog(jObj) {
($("#dialog-5").dialog("isOpen") == false) ? $("#dialog-5").dialog("open"): $("#dialog-5").dialog("close");
}发布于 2017-10-04 21:02:46
对于未来具有母版和内容页的visitors....the解决方案是在open或create对话框初始化中添加重新定位的代码行。
function (evt) { // @open
$(this).parent().appendTo("form");
}这会将对话框移回表单元素内
https://stackoverflow.com/questions/33992060
复制相似问题