开发者

UI confirmation not firing the event

I am using jQuery confirmation box within my listView and the confirmation box displayed with the user clicks delete. The problem that I am faced with, is that when the user clicks OK it, the lvAlbums_ItemDeleting event is not fired.

Below is the .aspx code:

<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>

Firebug throws the following error:

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

If anyone could provide a solution with the above, it would be greatly appreciated.

I have spent days looking at different jQuery confirmation box examples but this is the best I can do. Ideally I would want to be use http://jqueryui.com/demos/dialog/#modal-confirmation within gridviews, dataViews and ListViews but can't find examples which exactly provide steps to follow.

Thanks


Or you could use this:

    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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜