私はasp.net Webアプリケーションを開発しています。サーバーサイドを使用する必要があります。メッセージボックスはありません。サーバーサイド(コードの背後にある)はいいいえ確認メッセージボックスin ASP.Net C#
public void OnConfirm(object sender, EventArgs e)
{
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
}
}
:背後にあるコード
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to save data?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnConfirm" runat="server" OnClick = "OnConfirm" Text = "Raise Confirm" OnClientClick = "Confirm()"/>
</form>
</body>
</html>
コード以下のように良い解決策、
を発見していない私は、のみのみクライアント側のJavaScriptはい/いいえメッセージボックスを発見しました
しかし、この解決策は、私は完全にサーバー側のyes/noメッセージボックスasp.net C#..私は検索&を試したが、その部分的に実行しました。上記のコードで
protected void btnSave_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("confirm('");
sb.Append("Hi");
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm", sb.ToString());
string msg = "Do you want to save data?";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "confirm('" + msg + "')", true);
}
我々はオプションは、我々はそれが何のブロックを移動しないでする必要がありませオプションをクリックしないとき はいブロック/を移動する必要がありそうをクリックしたときに、私が必要です。
私はこれを行う方法がわからない..私はコード
protected void btnSave_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("confirm('");
sb.Append("Hi");
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm", sb.ToString());
string msg = "Do you want to save data?";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "confirm('" + msg + "')", true);
string confirmValue = Request.Form["confirm"];
if (confirmValue == "Yes")
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
}
}
の下にすべてのボディを試してみました が私を助けて...
からJavaScript関数を呼び出しますユーザーはデータセンターに入り、サーバーにログインして適切なボタンをクリックすることで、「サーバー側」ダイアログがどのように機能するのかよく分かりません。あなたは正確に何を達成しようとしていますか? –
あなたのお返事ありがとうございます、ごめんなさい、私を助けてくれない.. – Surya
"それは私を助けません" - もう一度、*あなたは何を達成しようとしていますか?あなたが*これをやりたいと思っているからといって、あなたができることはありません**。 –