Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a function to close a modal:

function closeModal(name) {
    $(name).modal('hide');
}

But, my page also has an update panel and I need to trigger it.

I tried __doPostBack('UpdatePanel1', '') with no luck.

Thanks

The problem is this:

$(document).ready(function () {
    createAutoClosingAlert('.success_alert', 6000);
    if(<%# IsAPostBack() %>){
        if(window.parent != null){
            window.parent.closeEditModal();
            window.parent.closeCalendarModal();
            window.parent.closeModal('#projectModal');
            window.parent.closeModal('#scheduleModal');
        }
    }
});

I call it from the parent so I cannot get the hidden ID.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

One option is to put a hidden button inside your update panel

<div style="display:none">
  <asp:Button ID="Button2" runat="server" Text="Button" />
</div>

Then call the following in your script

document.getElementById('<%=Button2.ClientID%>').click();

The button click will cause a postback.

You can also look at Page.GetPostBackEventReference


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...