【问题标题】:How to call a server side method on losing focus from a textbox, asp.net mvc如何在从文本框失去焦点时调用服务器端方法,asp.net mvc
【发布时间】:2010-07-23 05:09:00
【问题描述】:

我有两个文本框,一个用于“程序”,另一个用于“描述”。我有一组预定义的程序,它是数据库中的相关描述。

示例:对于名为“Test”的程序,它在 DB 表中的描述为“有效”

例如,当在程序文本框中输入程序名称为“测试”时,其关联的 描述“有效”应在“程序”文本框失去焦点时自动填充到“描述”文本框。

如何使用 asp.net mvc 实现这一点

【问题讨论】:

    标签: c# .net asp.net jquery asp.net-mvc


    【解决方案1】:

    文本框模糊事件和使用 ajax 调用的组合。

    $('#program').blur( function(){
    
       //make ajax call to action method to get the description for this value
       $.get(yourActionUrl, { data : $(this).val() }, function(response) {
    
          //set the value of description text box
          $('#description').val( response );
    
       });
    
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-23
      • 2015-01-09
      相关资源
      最近更新 更多