从 C# 文件单击按钮后如何从 javascript 调用 bootbox.alert()
How to call bootbox.alert() from javascript after button click from C# file
我想调用我在 JavaScript 函数 myfunction() 中编写的 "bootstrap.alert" 方法。
这是aspx代码:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="temp1.aspx.cs" Inherits="temp1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/font-awesome.min.css" rel="stylesheet" />
<script type="text/javascript">
function myfunction() {
bootbox.alert("Hello world!", function () {
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button runat="server" Text="Test" ID="btnTest" OnClick="btnTest_Click"/>
</form>
<!-- JS dependencies -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- bootbox code -->
<script src="Scripts/bootbox.js"></script>
<script src="Scripts/bootstrap.min.js"></script>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript"> </script>
</body>
</html>
这是我的 Csharp 代码:-
public partial class temp1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnTest_Click(object sender, EventArgs e)
{
//What should i write here to call the javascript function "myfunction()" and that bootbox.alert() is executed.
}
}
我想在点击按钮时显示 bootbox 警告框。请帮我在按钮点击事件中编写代码。
使用属性 onclientClick
<asp:Button runat="server" Text="Test" ID="btnTest" OnClick="btnTest_Click" OnClientClick="myFunction"/>
我想调用我在 JavaScript 函数 myfunction() 中编写的 "bootstrap.alert" 方法。
这是aspx代码:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="temp1.aspx.cs" Inherits="temp1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/font-awesome.min.css" rel="stylesheet" />
<script type="text/javascript">
function myfunction() {
bootbox.alert("Hello world!", function () {
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button runat="server" Text="Test" ID="btnTest" OnClick="btnTest_Click"/>
</form>
<!-- JS dependencies -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- bootbox code -->
<script src="Scripts/bootbox.js"></script>
<script src="Scripts/bootstrap.min.js"></script>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript"> </script>
</body>
</html>
这是我的 Csharp 代码:-
public partial class temp1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnTest_Click(object sender, EventArgs e)
{
//What should i write here to call the javascript function "myfunction()" and that bootbox.alert() is executed.
}
}
我想在点击按钮时显示 bootbox 警告框。请帮我在按钮点击事件中编写代码。
使用属性 onclientClick
<asp:Button runat="server" Text="Test" ID="btnTest" OnClick="btnTest_Click" OnClientClick="myFunction"/>