【问题标题】:execute different codes in code behind on confirm ok and cancel在确认 ok 和 cancel 时在后面的代码中执行不同的代码
【发布时间】:2013-11-21 04:31:31
【问题描述】:

我想在 text_changed 事件上有一条确认消息,并在确定和取消时执行不同的代码集。帮我看看这些代码

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

代码背后

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)
    {
    }

这样做是这样的,但我想不使用按钮,我只想使用文本框

【问题讨论】:

  • 你在哪里调用你的 JS 函数?
  • 请查看有问题的编辑
  • @geedubb 请帮帮我

标签: javascript jquery asp.net .net confirm


【解决方案1】:

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

https://stackoverflow.com/a/20117247/1381667

您似乎发布了 2 次相同的问题,完全可以,但如果您认为问题不能完美表达您的问题,请尝试编辑您的问题,而不是发布新问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    相关资源
    最近更新 更多