0

我是一个 jQuery 菜鸟,我正在尝试在 ASP.Net 网页中使用Eric Martin 的 SimpleModal Confirm Override 对话框。它不工作 - 毫不奇怪,我不知道我在做什么!这是我的 aspx 页面的简化版本:

<%@ 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>

当我运行该页面时,我看到了 Demo 按钮和 Demo 链接,但单击它们没有任何反应。我错过了什么?我可以在 ASP.Net 页面上使用 SimpleModal 吗?在内容控件中?非常感谢!

4

1 回答 1

0

这里有多个问题。

  • 带有 a的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>

于 2013-07-26T20:41:01.877 回答