I have a asp.net component inside a ColorBox window, and after choosing a country in
Dropdownlist auto postback happens(to automatically set states) and ColorBox closes, so how to stop ColorBox from closing during postback?
I want ColorBox only to close when user clicks exit button or save button
heres the jQuery code:
$(document).ready(function () {
if ($('#hdfContainsPrint').val() == 'True') {
window.location = document.location.href;
}
var $close = $('#cboxClose').appendTo('#cboxWrapper').css({ width: 22, top: 1, right: 1, zIndex: 9999, position: 'absolute' }).hide();
$("#<%=btnSearch.ClientID%>").colorbox({ inline: true, overlayClose: false, opacity: 0.8, href: "#inline-view", scrolling: false,
});
$('#colorbox').appendTo('form');
$("a[id=btnNewDok]").bind("click", __doc_create_envoke);
Markup:
<div style="display:none">
<div id="inline-view">
<uc1:myComponent ID="componentID" runat="server" Visible="true" />
</div>
</div>
The autopostback of the dropdown performs a form POST action, which forces the page to refresh. To prevent this, you must use an AJAX alternative. For example, you can place the dropdown inside an
UpdatePanel. TheUpdatePanelwill execute asynchronously without refreshing the page and thus maintaining your ColorBox.An example of how to use a
DropDownListwithAutoPostBackinside anUpdatePanelcan be found here.