【问题标题】:Issue getting my jquery dialog to open up and show问题让我的 jquery 对话框打开并显示
【发布时间】:2011-06-02 14:20:14
【问题描述】:

我有以下 javascript 函数

 <script type="text/javascript">
   function ShowAlert(id) {
     //  alert('I am here' + id);
       $(id).dialog('open');

   }

var dl;
$(document).ready(function () {
    //setup edit person dialog             
    $('#editPerson').dialog({
        //Setting up the dialog properties.
        show: "blind",
        hide: "fold",
        resizable: false,
        modal: true,
        height: 400,
        width: 700,
        title: "Modify Member"
    });
            $("#<%=ButtonAdd.ClientID %>").click(function () {
                var dl = $("#divDlg").dialog({
                    //Setting up the dialog properties.
                    show: "blind",
                    hide: "fold",
                    resizable: false,
                    modal: true,
                    height: 400,
                    width: 700
                });
               // dl.parent().appendTo(jQuery('form:first'));
            });


    //Adding a event handler for the close button that will close the dialog 
    $("a[id*=ButtonCloseDlg]").click(function (e) {
        $("#divDlg").dialog("close");
        return false;
    });

});

在我的编辑按钮的 gridviews 项目模板中,我有以下调用函数。哪个可以显示警报但无法显示对话框?是不是因为网格上发生的回发导致它关闭?

   <ItemTemplate>
       <asp:Button ID="ButtonEdit" runat="server" CausesValidation="false" 
            CommandName="EditMember" OnClientClick='ShowAlert("#editPerson");' 
            Text="Edit" />
   </ItemTemplate>

任何帮助将不胜感激。

【问题讨论】:

    标签: jquery asp.net vb.net gridview dialog


    【解决方案1】:

    我会非常谨慎地使用

    $("#<%=ButtonAdd.ClientID %>").click(...
    

    在客户端 JavaScript 代码中。

    更好的方法是使用 jQuery 的“attribute ends with”选择器。考虑到 ASP.Net 将您的 ID 从 ASPX 页面附加到其生成的 HTML 的末尾(尝试在页面加载到浏览器中后查看页面的源代码),这应该可以解决 - 假设是问题所在..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-16
      • 2018-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多