首先,按鈕並沒有啓動jquery對話框和 當頁面加載時,我檢查控制檯是否有錯誤,並得到「Uncaught TypeError:undefined is not功能」,它指向$( 「#對話」)。對話框({爲什麼我的ASP.NET按鈕控件沒有觸發JQuery對話框
這裏是我的代碼如下。
Default.aspx的
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="JavaScript1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CustomValidator runat="server" ID="cv1" ControlToValidate="fupCV" ClientValidationFunction="validate"></asp:CustomValidator>
<asp:FileUpload runat="server" ID="fupCV"/>
<asp:Button runat="server" ID="btnUpload" OnClick="btnUpload_OnClick" Text="Upload"/>
<asp:Button runat="server" ID="btnDialog" OnClientClick="return false;" Text="Open Dialog"/>
</div>
</form>
<div id="dialog" style="display: none">
This is a popup
</div>
</body>
</html>
JavaScript1.js
$(document).ready(function() {
$('#btnUpload').attr('disable', 'disable');
$("#dialog").dialog({
autoOpen: false,
height: 'auto',
width: 350,
modal: true,
resizable: false,
buttons: {
Accept: function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
$(this).dialog("close");
}
});
$("#btnDialog").click(function() {
$("#dialog").dialog("open");
});
});
感謝埃裏克,直截了當,簡潔!我沒有注意到這一點。 – 2014-10-17 17:12:19