1

asp.net code

 <asp:Button ID="btnnext" runat="server" Text="Update" onclick="btnnext_Click"  />

<div id= "DisplayEnteredDetails" >

<asp:GridView ID="grdDisplayEnteredDetails" runat="server"   >
                    </asp:GridView> 
</div>

calling function

  <script type="Text/javascript">
    $(function () {
     $('#DisplayEnteredDetails').dialog({
                autoOpen: false,
                width: 600,
                height: 500,
                hide: 'Transfer',
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });
     // Dialog button
            $('#ctl00_Main_btnnext').click(function () {
                $('#DisplayEnteredDetails').dialog('open');
                return false;
            });


        });   
    </script>

i gave the link in master page like

<link rel="stylesheet" type="text/css" href="~/styles/StyleSheet.css" />
    <link href="jquery/css/jquery.ui.all.css" rel="stylesheet" type="text/css" />

same code works in other project but not in my application

4

2 回答 2

0

替换<script type="Text/javascript">为just<script>并检查。脚本标签应全部为小写字母。所以,<script type="text/javascript">或者只是<script>应该工作。

否则您可能忘记在 html 中添加 jquery Ui 引用。(假设,因为它在您提供的代码中不可见)

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> 
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
于 2013-03-07T06:10:12.180 回答
0

要使用 jQuery 显示对话框,您需要做两件事:

  1. 下载 jQuery
  2. 下载 jQuery UI

将这两个文件放在您的项目中,并在页面/母版页上添加对它们的引用:

<script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.js" type="text/javascript"></script>

这是一个有效的完整示例:

PS:记得把脚本中按钮的id改成正确的值

<head runat="server">
    <title>Dialog</title>
    <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#DisplayEnteredDetails').dialog({
                autoOpen: false,
                width: 600,
                height: 500,
                hide: 'Transfer',
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });
            // Dialog button
            $('#ctl00_Main_btnnext').click(function () {
                $('#DisplayEnteredDetails').dialog('open');
                return false;
            });
        });  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="ctl00_Main_btnnext" runat="server" Text="Update" OnClick="btnnext_Click" />
    <div id="DisplayEnteredDetails" style="border:1px solid #2d2d2d;">
        <asp:GridView ID="grdDisplayEnteredDetails" runat="server">
        </asp:GridView>
    </div>
    </form>
</body>
于 2013-03-07T07:42:15.030 回答