开发者

asp.Net jquery Modal Dialog Form

开发者 https://www.devze.com 2023-02-23 10:25 出处:网络
Iam trying to open a pop up login form in jquery modal dialog on click of a button in a asp.net page. But the modal dialog is not coming as a pop up window.Please tell where Iam doing wrong.

Iam trying to open a pop up login form in jquery modal dialog on click of a button in a asp.net page. But the modal dialog is not coming as a pop up window.Please tell where Iam doing wrong.

here is my HTML code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModalForm.aspx.cs" Inherits="ModalForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery.js" type="text/javascript"></script>
    <link href="css/jquery.modaldialog.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.modaldialog.js" type="text/javascript"></script>
    <script type="text/javascri开发者_开发知识库pt">
        $(document).ready(function() {
            $("#dialog").dialog({
                bgiframe: true,
                autoOpen: false,
                height: 300,
                modal: true,
                buttons: {
                  Cancel: function() {
                    $(this).dialog("close");
                }
                },
                close: function() {
                allFields.val("").removeClass("ui-state-error");
                }
            });

            // Display the modal dialog.
            $("#btndialog").click(function() {

                $("#dialog").dialog("open");
            });

        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="dialog" title="Please Login">
          <asp:Login ID="LoginForm" runat="server" />  
        </div>
        <asp:Button ID="btndialog" runat="server" Text="Click"  />         
    </form>
</body>
</html>

thanks


The javascript code looks correct.

Check if .js files are found by the browser.

Otherwise, ASP.NET changes elements IDs, try using ClientID property:

    $(document).ready(function() {
        $("#<%= dialog.ClientID %>").dialog({
            bgiframe: true,
            autoOpen: false,
            height: 300,
            modal: true,
            buttons: {
              Cancel: function() {
                $(this).dialog("close");
            }
            },
            close: function() {
            allFields.val("").removeClass("ui-state-error");
            }
        });

        // Display the modal dialog.
        $("#<%= btndialog.ClientID %>").click(function() {

            $("#<%= dialog.ClientID %>").dialog("open");
        });

    });
0

精彩评论

暂无评论...
验证码 换一张
取 消