2011-02-13 47 views
0

我在我的listView中使用jQuery确认框,并且用户单击删除时显示确认框。 我面临的问题是,当用户点击确定后,事件不会被触发。UI确认未触发事件

下面是在.aspx代码:

<link href="jQuery/jquery-ui.css" rel="stylesheet" type="text/css" /> 
    <link href="jQuery/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" /> 
    <script src="https://www.google.com/jsapi?key=" type="text/javascript"></script> 
    <script type="text/javascript"> 
     google.load("jquery", "1"); 
     google.load("jqueryui", "1"); 
    </script> 
    <script type="text/javascript"> 
     $().ready(function() { 
      $('#dialogContent').dialog({ 
       autoOpen: false, 
       modal: true, 
       title: "MySql Membership Config Tool", 
       width: 300, 
       height: 250 
      }); 
     }); 

     function rowAction(uniqueID) { 

      $('#dialogContent').dialog('option', 'buttons', 
       { 
        "OK": function() { __doPostBack(uniqueID, ''); $(this).dialog("close"); }, 
        "Cancel": function() { $(this).dialog("close"); } 
       }); 

      $('#dialogContent').dialog('open'); 

      return false; 
     } 

</script> 

</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
<div id="thumbs"> 
     <asp:ListView ID="lvAlbums" runat="server" GroupItemCount="15" DataKeyNames="album_id"> 
      <LayoutTemplate> 
       <table id="groupPlaceholderContainer" runat="server" border="0" cellpadding="0" cellspacing="0" 
        style="border-collapse: collapse; width: 100%;"> 
        <tr id="groupPlaceholder" runat="server"> 
        </tr> 
       </table> 
      </LayoutTemplate> 
      <GroupTemplate> 
       <tr id="itemPlaceholderContainer" runat="server"> 
        <td id="itemPlaceholder" runat="server"> 
        </td> 
       </tr> 
      </GroupTemplate> 
      <ItemTemplate> 
       <div> 
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# "ThumbNail.ashx?ImURL=/uploads/"+Eval("photo_file_name") %>' 
         Width="130" Height="150" BorderStyle="None" /> 
        <asp:Label ID="lblPhotoTitle" runat="server" Text='<%# Eval("album_name") %>' CssClass="photoTitle"></asp:Label> 
        <br /> 
        <asp:Button ID="btnDeleteAlbum" runat="server" Text="Delete Album" Width="144px" OnClick="lvAlbums_ItemDeleting" OnClientClick="javascript:return rowAction(this.name);" 
         CommandName="Delete" /> 
       </div> 
      </ItemTemplate> 
     </asp:ListView> 
    </div> 
    <div class="pager"> 
     <asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvAlbums" PageSize="12"> 
      <Fields> 
       <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowPreviousPageButton="true" 
        ShowLastPageButton="false" ShowNextPageButton="false" ButtonCssClass="first" 
        RenderNonBreakingSpacesBetweenControls="false" /> 
       <asp:NumericPagerField CurrentPageLabelCssClass="current" NextPreviousButtonCssClass="next" 
        NumericButtonCssClass="numeric" ButtonCount="10" NextPageText=">" PreviousPageText="<" 
        RenderNonBreakingSpacesBetweenControls="false" /> 
       <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false" 
        ShowLastPageButton="true" ShowNextPageButton="true" ButtonCssClass="last" RenderNonBreakingSpacesBetweenControls="false" /> 
      </Fields> 
     </asp:DataPager> 
    </div> 
    </div> 

    <div id="dialogContent"> 
     <h3>confirm</h3> 
     <p>Click ok to accept</p> 
    </div> 

    </form> 

</body> 

萤火虫引发以下错误:

__doPostBack is not defined 
[Break On This Error] "OK": function() { __doPostBa...ID, ''); $(this).dialog("close"); }, 

如果任何人都能够提供与上述的溶液中,将不胜感激。

我花了好几天看着不同的jQuery确认框的例子,但这是我能做的最好的。理想情况下,我希望在gridviews,dataViews和ListViews中使用http://jqueryui.com/demos/dialog/#modal-confirmation,但找不到可准确提供步骤的示例。

感谢

回答

0

或者你可以使用这个:

protected void Page_PreRender(object sender, EventArgs e) 
    { 
     //If the page doesn't have a control that causes a postback, __doPostBack() won't be output 
     //as a function definition. One way to override this is to include this line in your Page_PreRender(): 

     Page.ClientScript.GetPostBackEventReference(this, string.Empty); 
     //This function returns a string calling __doPostBack(); but also forces the page to output 
     //the __doPostBack() function definition.    
    } 
+0

我几乎可以肯定发现这个对SO,但无法找到邮局为我的生活。 – 2014-03-05 23:55:40