如何从盒子确认在code反应背后 [英] How to get the response from Confirm box in the code behind

查看:104
本文介绍了如何从盒子确认在code反应背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的。我asp.net/C#我想创建一个Web应用程序。

I am new to asp.net/C# .I am trying to create a web application.

下面是我的要求。

我想,以节省按钮点击的记录。保存记录之前,如果该记录在数据库中存在或不(在code后面)。如果它存在,那么我需要显示一个警告以用户为记录已经exist.Do你,我会检查要继续吗?当用户preSS'是',我需要继续我保存在code中的记录,否则我只需要退出保存过程。

I am trying to save a record on button click. Before saving the record,I will be checking if that record exist in the database or not(in the code behind).If it exist,then I need to show an alert to the user as "Record already exist.Do you want to proceed?"When the user press 'Yes',I need to continue my save for the record in the code ,else I just need to exit the save process.

//......code for checking the existence of the record    
if (check == true)
{            
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", " confirm('Record already exist.Do you want to proceed?');", true);
}
//

以上code显示我确认OK和取消按钮框。
我的问题是

The above code shows me confirm box with 'OK' and 'Cancel' buttons. My questions are


  1. 我怎么可以把它是或否的确认对话框?

  2. 用户preSS'是'/'不',我怎么能赶上响应(是/否),并继续与我的节目休息吗?
  3. 之后

我已经寻找这个lot.But不能得到适当的answer.Please帮助我在此。

I have searched for this a lot.But couldn't get a proper answer.Please help me on this.

推荐答案

您可以使用确认框在JS这样

You can use confirm box in JS like this

var ans = confirm ('Record already exist.Do you want to proceed?');
if(ans==true)
{
}
else
{
}

其次,要获取code反应的背后,你可以存储是/否值转换成一个隐藏字段例如

Secondly, to get the response in code behind, you can store the Yes/No value into a hidden field e.g.

document.getElementById('<%= hiddenField.ClientID %>').value = ans;

这篇关于如何从盒子确认在code反应背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆