【问题标题】:Different popup for textbox change?文本框更改的不同弹出窗口?
【发布时间】:2010-12-01 02:54:23
【问题描述】:

我在公司页面中有 10 个文本框。其中 5 个在 Location 页面中很常见。 我的目标是询问用户是否只想更新公司页面甚至位置页面。如果用户更改了 5 个文本框 在位置页面中很常见,弹出窗口显示为“您是否也想更新位置页面”或者如果用户更改了其他 5 个,则弹出窗口显示 “要保存吗?”

我们如何确定更改了哪些文本框以及应该显示哪个弹出窗口?有人可以帮帮我。谢谢大家:)

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    其中一种方法是:

    1. 安装 jquery(只是为了更容易访问控件)
    2. 将class='common' 之类的类名分配给第一组文本框
    3. 将另一个类名(如 class='other')分配给第二组文本框
    4. 处理 'commons' 的 onblur 事件:

      $(":input.common").blur(function() {
        if ($(this).data("changed") && confirm("Do you want to update Location Page as well?")) {
          // TODO: perform update
        }
      }).keydown(function(e) {
        $(this).data("changed", true);
      }).focus(function(e) {
        $(this).data("changed", false);
      });
      
    5. 处理“其他人”的 onblur 事件:

      $(":input.other").blur(function() {
        if ($(this).data("changed") && confirm("Do you want to save?")) {
          // TODO: perform save
        }
      }).keydown(function(e) {
        $(this).data("changed", true);
      }).focus(function(e) {
        $(this).data("changed", false);
      });
      

    有想法吗?

    【讨论】:

    • 你真是天才。谢谢! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多