我是JQuery的新手,並嘗試在用戶單擊aspx按鈕時顯示「是/否」確認對話框。當對話框顯示給用戶時,他可以點擊是或否按鈕,並根據用戶的行動,我想執行不同的代碼存在於代碼後面的文件,即在aspx.cs如何在asp上顯示Jquery對話框:按鈕單擊
我試着用下面的代碼但沒有成功實現我的目標。
代碼出現在aspx頁面:
<link href="jquery-ui-1.8.10.custom.css" rel="stylesheet" type="text/css" />
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function() {
jQuery("#myButton").click(showDialog);
//variable to reference window
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.dialog({
autoOpen: false,
width: 400,
modal: true,
resizable: false,
buttons: {
"Yes": function() {
},
"No": function() {
$(this).dialog("close");
}
}
});
}
);
//function to show dialog
var showDialog = function() {
//if the contents have been hidden with css, you need this
$myWindow.show();
//open the dialog
$myWindow.dialog("open");
}
//function to close dialog, probably called by a button in the dialog
var closeDialog = function() {
$myWindow.dialog("close");
}
</script>
<form id="testconfirmJQ" name="testconfirmJQ" runat="server">
<fieldset>
<legend>jQuery UI Modal Submit</legend>
<p><label for="email">E-mail:</label><br />
<input id="emailJQ" type="text" name="emailJQ" value="" /></p>
<p>
<asp:Button ID="myButton" runat="server" Text="Button" onclick="myButton_Click" />
</fieldset>
</form>
<div id="myDiv" title="Verify Form jQuery UI Style"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 0 0;"></span> You entered your e-mail address as:</p><p id="dialog-email"></p><p>
If this is correct, click Submit Form.</p><p>To edit, click Cancel.<p></div>
</form>
在事件處理程序的代碼背後,現在是空的。任何建議將不勝感激!
您遇到的問題是什麼?當用戶點擊是或否時,您是否需要幫助創建特定帖子? – 2011-03-11 16:42:20