ASP.net页面
<script type="text/javascript" language="javascript">
function show_confirm() {
var r = confirm("Are you sure you want to Save this Transaction");
if (r == true) {
$('#<%=btnConfirm.ClientID%>').click();
}
else {
}
}
</script>
<asp:Content ID="detailContent" ContentPlaceHolderID="mainContentPlaceholder"
runat="server">
<asp:LinkButton ID="LinkButton1" runat="server"
CssClass="primary positive big button" OnClientClick="return show_confirm();return false"><span class="check icon"></span>Save Transaction</asp:LinkButton>
<asp:Button ID="btnConfirm" runat="server" Style="display: none;" onclick="btnConfirm_Click"/>
</content>
如果用户在弹出消息框中单击“是”,则会触发btnConfirm单击。
在页面上查看IE上的源
<a onclick="return show_confirm();return false;" id="ctl00_mainContentPlaceholder_LinkButton1" class="primary positive big button" href="javascript:__doPostBack('ctl00$mainContentPlaceholder$LinkButton1','')">
<span class="check icon"></span>Save Transaction</a>
<input type="submit" name="ctl00$mainContentPlaceholder$btnConfirm" value="" id="ctl00_mainContentPlaceholder_btnConfirm" style="display: none;" />
表示感谢
答案 0 :(得分:0)
show_confirm()
函数不返回布尔值。它应该返回一个值才能正常工作。
为什么不像下面这样做,它会做你想要的。
<asp:LinkButton ID="LinkButton1" runat="server"
CssClass="primary positive big button" OnClick="LinkButton1_Click"
OnClientClick="return confirm('Are you sure you want to Save this Transaction');">
<span class="check icon"></span>Save Transaction </asp:LinkButton>