按钮不会执行.click与Asyncpostbacktrigger

时间:2012-08-10 17:05:21

标签: javascript asp.net html asynchronous

我有一个通过javascript rightnow运行的删除功能。您选择网格上的行,点击删除按钮1,弹出一个包含删除按钮2的弹出窗口。单击时删除按钮2会触发连接到我的c#代码的隐形按钮上的.click事件以进行删除。

这一切都很好用,直到我将隐形按钮设置为asyncpostbacktrigger。现在删除按钮2运行隐藏弹出命令,但不会触发.click事件。有什么想法吗?

来源

<script type="text/javascript">
    //execute popup
    function popup() {
        $("#popupbg").animate({ opacity: ".8" });
        $("#delete, #update").click(
            function() {
                var id = $(this).attr("id")
                {
                    if (id == "delete") {
                        $("#popupbg, #lidelete, #butdelete, #butcancel").show('fast');
                    }
                    else if (id == "update") {
                        $("#popupbg, #liupdate, #butupdate, #butcancel").show('fast');
                    }
                }
            });

    }
    //execute popup cancel
    function popupcancel() {
        $("#popupbg, #liupdate, #butupdate, #butcancel, #lidelete, #butdelete").hide('medium');
    }
    //execute popup delete
    function popupdel() {
            var button = document.getElementById("execdelete");
            button.click();
            $("#popupbg, #lidelete, #butdelete, #butcancel").hide('medium');
        }
    //execute popup update
    function popupupdate() {
        var button = document.getElementById("execupdate");
        button.click();
        $("#popupbg, #liupdate, #butupdate, #butcancel").hide('medium');
    }
</script>

<div id="popupbg"> 
</div> 

<div id="popupbgitembg">
<ul class="popupbgitems">
        <li id="lidelete">
            Are you sure you want to delete?
        </li> 
        <li id="liupdate">
            Are you sure you want to update?
        </li>
        <li></li> 
        <li>
            <input type="submit" name="execdelete" value="" id="execdelete" class="invisible" />
            <input type="submit" name="execupdate" value="" id="execupdate" class="invisible" />
            <input type="submit" name="butupdate" value="Yes" onclick="javascript:scroll;popupupdate();" id="butupdate" style="font-size:11px;width:70px;" />
            <input type="submit" name="butdelete" value="Yes" onclick="javascript:scroll;popupdel();" id="butdelete" style="font-size:11px;width:70px;" />
            <input type="submit" name="butcancel" value="No" onclick="javascript:popupcancel();" id="butcancel" style="font-size:11px;width:70px;" />

        </li>
    </ul>
</div>    

<li class="lblinfo"><span id="lblGLDeptData"></span></li>
                    <li><input type="submit" name="update" value="Update" onclick="javascript:popup(); ;" id="update" style="width:70px;font-size:11px" />
                        <input type="submit" name="delete" value="Delete" onclick="javascript:popup();" id="delete" style="width:70px;font-size:11px" />

                   </li>
                </ul>
            </div>            
</div>

    <div id="gvMappingupdate">

            <div id="headerdiv">
            </div>
            <div id="topcontentcover"></div>
            <div class="topcontent">
                <div>
</div>
                <input type="submit" name="btnGetGLDept" value="" id="btnGetGLDept" class="invisible" />
                <div id="gvMappingprogress" style="display:none;">

                        <div class="load"><img src="Images/loading.gif" alt="Loading" /></div>

</div>

的javascript

function popup() {
    $("#popupbg").animate({ opacity: ".8" });
    $("#delete").click(function() {
        $("#popupbg, #popupbgitembg").show('fast')
    });
}

function popupcancel() {
    $("#popupbg, #popupbgitembg").hide('medium');
}

function popupdel() {
    var button = document.getElementById("<%= execdelete.ClientID %>");
    button.click();

    $("#popupbg, #popupbgitembg").hide('medium');
}

HTML

<div id="popupbg"> 
</div> 
<div id="popupbgitembg">
<ul class="popupbgitems">
        <li>
            Are you sure you want to delete?
        </li> 
        <li></li> 
        <li>
            <asp:Button ID="execdelete" runat="server" CssClass="invisible" OnClick="delSysGLDepts" />
            <asp:Button ID="butdelete" runat="server" Text="Delete" OnClientClick="javascript:scroll;popupdel();" Font-Size="11px"/>
            <asp:Button ID="butcancel" runat="server" Text="Cancel" OnClientClick="javascript:popupcancel();" Font-Size="11px"/>

        </li>
    </ul>
</div>  

我的异步回发部分

</asp:UpdatePanel>
    <%--Mapping Top Content --%>
    <asp:UpdatePanel ID="gvMappingupdate" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="mapsearch" EventName="Click"  />
            <asp:AsyncPostBackTrigger ControlID="execdelete" EventName="Click" />
        </Triggers>
        <ContentTemplate>

1 个答案:

答案 0 :(得分:0)

试试这个:

function popupdel() {
    $('#execdelete').click();
    $("#popupbg, #popupbgitembg").hide('medium');
}