[英]In asp.net button onclick and onclientclick not working for alert and confirm methods in javascript
<asp:Button ID="btnSubmit" runat="server" style=" float:left" Text="Submit" `OnClientClick="submitRequest();" onclick="btnSubmit_Click" TabIndex="8"/>`
和
<script type="text/javascript">
function submitRequest() {
var hdn_YearlyAvailableFund = parseFloat("<%= hdnYearlyAvailableFund.Value %>");
var hdn_Amount = parseFloat("<%= hdnAmount.Value %>");
var hdn_QueryString = "<%= hdnQueryString.Value %>";
var approve = document.getElementById("<%=rdbApprove.ClientID %>");
var check = approve.checked;
if (hdn_QueryString.toString() == 'X') {
if (approve.checked == true) {
if (hdn_YearlyAvailableFund < hdn_Amount) {
alert('Yearly available fund is less than Requested Amount, Cannot approve...!')
}
else {
if (confirm('Are you sure want to update this request?'))
document.getElementById('<%= btnSubmit.ClientID %>').click();
}
}
}
else {
if (confirm('Are you sure want to update this request?')) {
document.getElementById('<%= btnSubmit.ClientID %>').click();
}
}
}
</script>
在我的代碼中,警報和確認方法沒有一起工作。
我要求給我一個解決方案。 提前致謝。
嘗試添加術語return
; 你必須返回一個值:
return confirm('Are you sure want to update this request?')
也適用於OnClientClick
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.