如何从服务器端的确认框中读取值? [英] How to read the values from Confirmation Box in Server side?

查看:54
本文介绍了如何从服务器端的确认框中读取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我有一个下拉列表,其中包含一些状态值和一个提交按钮。点击提交按钮,我发送邮件。



对于下拉菜单中的一个特定状态,点击提交按钮后,我显示一个确认或取消的确认框。我从Code back页面调用它(即C#)。根据这个选择,我需要执行一个代码块。对于确定我正在调用一种方法来发送邮件和取消我应该留在页面上而不发送邮件。



那么如何读取.cs页面中的确认框中的值(代码隐藏)?



请注意我无法实现这一点在提交按钮的OnClientClick事件上,因为我只想在下拉列表中的一个状态的确认框。所有这一切都需要在提交按钮的OnClick事件上完成。



请帮我解决这个问题。



TIA。

Hi everyone,


I have a dropdown list which contains some status values and a submit button.By clicking on submit button,I am sending a mail.

For one specific status in dropdown, after clicking Submit button,I am showing a Confirm box with "Ok" or "Cancel". I am invoking this from Code behind page (i.e.,C#). Based on this selection I need to execute a block of code.For "Ok" I am calling a method to send mail and for "Cancel" I should stay I on the page without sending mail.

So how to read the values from Confirm box in .cs page(Code behind)?

Please note that I can't implement this on OnClientClick event of Submit button because I want the Confirm box only for one status in the dropdown. So all this needs to be done on OnClick event of submit button.

Please help me to solve this problem.

TIA.

推荐答案

你的按钮应该是这样的:



Your button should be like this:

<asp:ButtonID="btnSendMail" runat="server" OnClick="btnSendMail_Click"

                OnClientClick="return confirmation();" /></div>









客户端:







client side:

function confirmation() {
           if (confirm("Are you sure?"))
               return true;
           else return false;
       }





服务器端:





Server side:

protected void btnSendMail(object sender, EventArgs e)
       {
           //Your Code
       }









希望这会有所帮助。



干杯





Hope this helps.

Cheers


点击按钮,

In your button click,
if(dropdown.SelectedItem==SpecificItem)
{
 ClientScriptManager CSM = Page.ClientScript;
            string strconfirm = "<script>if(window.confirm(' Are you sure?'))........</script>";
            CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, true);
}


<asp:Button id="btnSendMail"  runat="server"



          Text="Client Click"



          OnClientClick="if(!confirm('Are you sure you want to Send Mail?'))
          return false;"   onclick="btnSendMail_Click"/>

  </div>


这篇关于如何从服务器端的确认框中读取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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