[英]How to open Colorbox jquery plugin modal window from asp.net code behind?
[英]How to open a modal poppup window in asp.net?
這是我的Java腳本代碼:
<script>
$('#<%= btnOpen.ClientID %>').click(function (e) {
e.preventDefault();
$('#content').modal({ onOpen: function (dialog) {
dialog.overlay.fadeIn('slow', function () {
dialog.data.hide();
dialog.container.fadeIn('slow', function () {
dialog.data.slideDown('slow');
});
});
},
onClose: function (dialog) {
dialog.data.fadeOut('slow', function () {
dialog.container.slideUp('slow', function () {
dialog.overlay.fadeOut('slow', function () {
$.modal.close(); // must call this!
});
});
});
}
});
</script>
還有我的按鈕
<td>
<asp:Button ID="btnOpen" runat="server" Text="Open" ClientIDMode="Static" />
</td>
在這種情況下,僅單擊按鈕的頁面將刷新
您是否嘗試過此鏈接: http : //www.codeproject.com/Articles/34996/ASP-NET-AJAX-Control-Toolkit-ModalPopupExtender-Co
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<asp:button id="Button1" runat="server" text="Button" />
<cc1:modalpopupextender id="ModalPopupExtender1" runat="server"
cancelcontrolid="btnCancel" okcontrolid="btnOkay"
targetcontrolid="Button1" popupcontrolid="Panel1"
popupdraghandlecontrolid="PopupHeader" drag="true"
backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>
<asp:panel id="Panel1" style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader">Header</div>
<div class="PopupBody">
<p>This is a simple modal dialog</p>
</div>
<div class="Controls">
<input id="btnOkay" type="button" value="Done" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
試試這個來限制回發:
<asp:Button ID="btnOpen" runat="server" Text="Open" ClientIDMode="Static" OnClientClick="return false;" />
我建議添加一個文檔准備好的聲明
<script>
$(document).ready(function(e){
//rest of your script here
});
</script>
還要提到的另一件事是, 如果您知道按鈕的特定ID就是這樣引用它的
$('#btnOpen').click(function(e){
e.preventDefault();
//rest of your script here
});
最終結果:
<script>
$(document).ready(function(){
$('#btnOpen').click(function(e){
e.preventDefault();
if(!HttpContext.Current.Session["UserID"]){
//userID exists show form code
//rest of original code here
} else {
//do something else or nothing
}
});
});
</script>
<asp:Button ID="btnOpen" runat="server" Text="Open" ClientIDMode="Static"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.