JQuery的模式弹出 [英] JQuery Modal Popup

查看:95
本文介绍了JQuery的模式弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图有一个modalpopup出现一次一个按钮被点击一个asp.net页面上。

I'm attempting to have a modalpopup appear once a button has been clicked on an asp.net page.

   <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestFile.ascx.cs" Inherits="TestFile" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.IO" %>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>jQuery UI Example Page</title>
        <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
        <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
        <script type="text/javascript"> 

                function fnmodalpopup() {
        $( "#dialog-modal" ).dialog({
            height: 140,
            modal: true
});
        </script>
    </head>

    <!--Misc functions for operations -->
    <script runat="server" type="text/javascript">

    </script>

    <div id="dialog-modal" title="Basic modal dialog">
        <p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
    </div>

    <asp:Button ID="Button1" runat="server" Text="Button" />

我试图创建一个对话框,酷似 http://jqueryui.com/demos/对话框/#模式,而是通过点击一个按钮,一个asp.net的形式触发。该页面出现闪烁,什么都没有。

I'm trying to create a dialog box exactly like http://jqueryui.com/demos/dialog/#modal, but triggered in an asp.net form by clicking a button. The page flashes and nothing appears.

任何反馈将是非常有益!

Any feedback would be very helpful!

推荐答案

您应该使用的OnClientClick事件,然后prevent与回发的返回false 是这样的:

You should use OnClientClick event and then prevent the postback with return false like this:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return fnmodalpopup()" />

function fnmodalpopup() {   
    $( "#dialog-modal" ).dialog({
        height: 140,
        modal: true
    });
    return false;
});

编辑:

我已经改变了的OnClientClick =收益 fnmodalpopup()

现在,它的工作原理确定(至少在我测试)。


I've changed OnClientClick="return fnmodalpopup()"
Now it works OK (at least when I tested it).

只是好奇,你为什么要使用服务器端组件,如果你不希望创建回传?如果没有的情况时,这个按钮必须做回发,可能效果会更好地使用HTML标记按钮(或任何其他的HTML标签,赶上点击与jQuery的事件)。如果您在页面的其余部分使用asp.net控制不要紧。

Just curious, why do you want to use server-side component if you don't want to create postback? If there is no situation when this button have to do postback, perhaps it would be better to use html button tag (or any other html tag and catch 'click' event with jQuery). It doesn't matter if you use asp.net controls on the rest of the page.

这篇关于JQuery的模式弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆