2015-11-30 70 views
1

我有一個asp.net應用程序,並在右上角我想顯示「聯繫我們」鏈接。點擊這個鏈接按鈕後,應該打開一個彈出窗口,並且休息區應該變灰。DialogBox代碼主頁

現在,要在所有應用頁面中顯示聯繫我們,必須將其添加到母版頁。下面是我試圖修改的母版代碼,但不知何故對話框沒有打開。由於放置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> 
+0

,能得到任何異常中? –

+0

不。當我點擊聯繫我們時,它只是重新加載頁面。 – user1630575

+0

將警報消息放在按鈕單擊並檢查您的按鈕單擊是否正常工作。 –

回答

1

如果頁面重新加載導致此問題,請嘗試這種方式。

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"); 
} 
+0

我試過了,沒有任何幫助。 – user1630575

+0

在開發人員控制檯中檢查元素DIV中是否存在dom中的id'dialog-5'? – Prabhat

0

對於未來的遊客....與主頁和內容頁的解決方案是增加的重新定位線代碼在opencreate對話框初始化中。

function (evt) { // @open 
    $(this).parent().appendTo("form"); 
} 

這將移動對話框後面的表單元素