在我的asp.net页面中
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="QDCM.Site.Speaker.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Colorbox practice</title>
<link href="../Styles/css/colorbox.css" rel="stylesheet" />
<script src="../../Scripts/jquery-1.10.2.js"></script>
<script src="../Styles/js/jquery.colorbox.js"></script>
<script type="text/javascript">
function openColorBox() {
$.colorbox({ width: "80%", height: "80%", iframe: true, href: "../QD/AddDocmnts.aspx" });
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="This should also work!" OnClientClick="openColorBox();" />
<input type="button" value="this works!" onclick="openColorBox()" />
</div>
</form>
此<input type="button" value="open color box" onclick="openColorBox()" />
工作正常,Colorbox在html按钮onclick
事件上正确弹出
但是,在这
<asp:Button ID="Button1" runat="server" Text="This should also work!" OnClientClick="openColorBox();" />
asp.net按钮,它似乎不能正常工作,
弹出颜色框,然后立即自动关闭,
我们如何在asp.net按钮中使用它?
答案 0 :(得分:1)
尝试
<asp:Button ID="Button1" runat="server" Text="This should also work!" OnClientClick="openColorBox(); return false;" />
这是取消按钮的默认回发