2013-07-26 32 views
0

我是一個總的jQuery noob,我試圖在ASP.Net網頁中使用Eric Martin's SimpleModal Confirm Override dialog box。它不工作 - 毫不奇怪,我不知道我在做什麼!這裏是我的aspx頁面的一個簡化版本:我SimpleModal的實現不起作用

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Reimbursements.aspx.cs" Inherits="EAS.telecom.Reimbursements" MasterPageFile="~/common/default.master" Title="Reimbursements" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

<%@ MasterType VirtualPath="~/common/default.master" %> 

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
    <script type='text/javascript' src='~/jquery/confirm/js/jquery.js'></script> 
    <script type='text/javascript' src='~/jquery/confirm/js/jquery.simplemodal.js'> 
     $.modal('#confirm');</script> 
    <script type='text/javascript' src='~/jquery/confirm/js/confirm.js'></script> 
    <script language="javascript" type="text/javascript"> 
     //some regular javascript here 
</script> 
<asp:Panel runat="server" ID="pnlEmployeeInfo" Enabled="false"> 
<div id='content'> 
     <div id='confirm-dialog'> 
      <h3>Confirm Override</h3> 
      <p>A modal dialog override of the JavaScript confirm function. Demonstrates the use of the <code>onShow</code> callback as well as how to display a modal dialog confirmation instead of the default JavaScript confirm dialog.</p> 
      <input type='button' name='confirm' class='confirm' value='Demo'/> or <a href='#' class='confirm'>Demo</a> 
     </div> 

     <!-- modal content --> 
     <div id='confirm'> 
      <div class='header'><span>Confirm</span></div> 
      <div class='message'></div> 
      <div class='buttons'> 
       <div class='no simplemodal-close'>No</div><div class='yes'>Yes</div> 
      </div> 
     </div> 
     <!-- preload the images --> 
     <div style='display:none'> 
      <img src='~/jquery/confirm/img/confirm/header.gif' alt='' /> 
      <img src='~/jquery/confirm/img/confirm/button.gif' alt='' /> 
     </div> 
    </div> 
    //more controls, including an AJAX TabContainer 
    </asp:Panel></asp:Content> 

當我運行網頁,我看到了演示按鈕和演示鏈接,但點擊他們什麼都不做。我錯過了什麼?我可以在ASP.Net頁面上使用SimpleModal嗎?在內容控件中?非常感謝!

回答

0

這裏有多個問題。

  • 一個script標籤與src也不能含有腳本主體。所以,這是無效的。

    <script src='~/jquery/confirm/js/jquery.simplemodal.js'>$.modal('#confirm');</script>

  • 如果您使用的ID,SimpleModal被稱爲像這樣:$('#content').modal();

  • 調用的需求是一個單擊事件處理程序中。

    <script> $(document).ready(function() { $('a.confirm').click(function() { $('#content').modal(); }); }); </script>

+0

好的,謝謝,我在哪裏把click事件處理程序? – Melanie

+0

更新爲防錯。你可以把標籤放在你喜歡的任何地方。 – Brian

+0

使我感到困惑的部分原因是,腳本代碼與click事件處理程序包含在confirm.js腳本文件(從SimpleModal下載)中,我在腳本標記中引用該文件。我是否還必須在我的aspx頁面中使用click事件處理程序的腳本標記? – Melanie

相關問題