Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在ASP.NET中显示确认消息框c_C#_Asp.net_Deployment - Fatal编程技术网

C# 在ASP.NET中显示确认消息框c

C# 在ASP.NET中显示确认消息框c,c#,asp.net,deployment,C#,Asp.net,Deployment,我在研究时发现了这些代码,但它们不是我真正想要的: 第一个解决方案: private void MsgBoxConfirmDelete(string sMessage) { string msg = "<script language=\"javascript\">"; msg += "var conf = confirm('Are you sure you want to delete this image?');"; msg += " if(conf =

我在研究时发现了这些代码,但它们不是我真正想要的:

第一个解决方案:

private void MsgBoxConfirmDelete(string sMessage)
{
    string msg = "<script language=\"javascript\">";
    msg += "var conf = confirm('Are you sure you want to delete this image?');";
    msg += "  if(conf == true){ (alert(....));}";
    msg += "</script>";
    Response.Write(msg);
}
private void MsgBoxConfirmDelete(字符串sMessage)
{
字符串msg=“”;
msg+=“var conf=confirm('您确定要删除此图像吗?');”;
msg+=“如果(conf==true){(警报(..);}”;
味精+=”;
响应。写入(msg);
}
第二种解决方案:

protected void Button1_Click(object sender, EventArgs e) 
{ 
    ClientScriptManager CSM = Page.ClientScript; 
    if (!ReturnValue()) 
    { 
        string strconfirm = "<script>if(!window.confirm('Are you sure?')){window.location.href='Default.aspx'}</script>"; 
        CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false); 
    } 
} 
bool ReturnValue() 
{ 
    return false; 
}
受保护的无效按钮1\u单击(对象发送者,事件参数e)
{ 
ClientScriptManager CSM=Page.ClientScript;
如果(!ReturnValue())
{ 
string strconfirm=“如果(!window.confirm('you sure?'){window.location.href='Default.aspx'}”;
RegisterClientScriptBlock(this.GetType(),“Confirm”,strconfirm,false);
} 
} 
布尔返回值()
{ 
返回false;
}
我找到的大多数解决方案都是“onclientclick/onclick”,但是我需要的是在运行我的方法时显示一条确认消息,这有点“介于两者之间”。因此,我非常需要一个IF/ELSE。有人知道如何从这样的确认消息中检索结果吗

例如:

消息:读取时发现一些重复数据,您确定 想继续吗?提示:是/否


对异步请求处理做一些研究。客户端web代码需要回拨服务器,以检索数据处理过程中更新的“状态”。服务器代码可以发回一般状态(即200条记录中有15条记录已完成),也可以发回信号提示用户确认。

使用ModalPopupXtender(ajax控件)。 在按钮上单击“显示弹出窗口”。
在控件中,为容器提供targetControlID,该容器包含要显示的消息和两个相应的按钮以进行确认。

我在web上找到了本教程,它似乎运行正常:

            if (MessageBox.Show("Are you sure you want to delete this list and it's related jobs? There is no going back!","Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
               // a 'DialogResult.Yes' value was returned from the MessageBox
               // proceed with your deletion
            }

用于winform应用程序:(