在OK确认在code后面执行不同的codeS和取消 [英] execute different codes in code behind on confirm ok and cancel

查看:162
本文介绍了在OK确认在code后面执行不同的codeS和取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有text_changed事件确认消息,就ok了C $ CS执行一套不同的$并取消。帮我看看这些codeS

I want to have a confirm message on text_changed event and execute different set of codes on ok and cancel. Help me with these codes

<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>

 <asp:TextBox ID="TextBox1" runat="server"  ontextchanged="TextBox1_TextChanged"></asp:TextBox>


code背后

Code Behind

protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
       // TextBox1.Attributes.Add("OnClientClick", "Confirm()");
        string confirmValue = Request.Form["confirm_value"];
        if (confirmValue == "Yes")
        {
            //Your logic for OK button
        }
        else
        {
            //Your logic for cancel button
        }
    }
 public void OnConfirm(object sender, EventArgs e)
    {
    }

这是这样做的,但我想这样做,而无需使用按钮,我想用文本框仅

It is done like this, But I want to do it without using button, I want to use textbox only

推荐答案

您可以从下面的链接找到答案。

You can find answer from following link.

<一个href=\"http://stackoverflow.com/a/20117247/1381667\">http://stackoverflow.com/a/20117247/1381667

看来你张贴同样的问题的2倍,这是完全确定,但尝试,如果你认为这是不是前preSS你的问题很好,而不是发布新来编辑你的问题。

It seems that you post same question 2 times, It is perfectly ok but try to edit your question if you think it is not express your problem perfectly instead of posting new one.

这篇关于在OK确认在code后面执行不同的codeS和取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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