などの代替に切り替えてBootstrap.Simpleを使用して初心者のための本当に簡単な例でコピーして、以下のコードを貼り付けそして、それは動作します:背後
コード(.csファイルのファイル):
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick_Click(object sender, EventArgs e)
{
lblOutput.Text = String.Empty;
bool showModal = true;
if(showModal)
ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#myModal').modal('show');", true);
}
protected void Decision_Command(object sender, CommandEventArgs e)
{
lblOutput.Text = "User clicked - " + e.CommandArgument;
}
.ASPX:は
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnClick" runat="server" Text="OK" OnClick="btnClick_Click" />
<asp:Label ID="lblOutput" runat="server"></asp:Label>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Would you like to continue?</h4>
</div>
<div class="modal-body">
<h3>Would you like to coninue?</h3>
<asp:Button ID="btnYes" runat="server" Text="Yes" OnCommand="Decision_Command" CommandArgument="Yes" />
<asp:Button ID="btnNo" runat="server" Text="No" OnCommand="Decision_Command" CommandArgument="No" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
出力:
![Popup confirmation using Bootstrap](https://i.stack.imgur.com/uaQWB.png)
あなたが何をしようとしたのですか?それはまっすぐです。 –
あなたは何を使って作業しようとしているかを示すコードはありますか? js関数を指すようにclickイベントのボタンを設定することができます。関数では、条件をチェックし、confirm();を使用します。 – Fredd
私は変数AとBの2つの値を持っています。私は、AがBよりも低く、**挿入コマンド**を実行していることを確認したいと思います。 AがBよりも低くない場合は、メッセージボックスがポップアップされ、その挿入コマンドを実行するための確認を求める必要があります。ユーザーが「はい」をクリックすると、コマンドは実行され、「いいえ」ボタンがクリックされた場合は何も実行されません。 –