如何调用服务器端方法从一个文本框,asp.net mvc的失去焦点 [英] How to call a server side method on losing focus from a textbox, asp.net mvc
问题描述
我有两个文本框,一是isfor'计划',另一个是'说明'。我有一个predefined设定的程序和它相关联的数据库中的描述。
I have two textboxes, one isfor 'program' and the other for 'description'. I have a predefined set of programs and it is associated descriptions in the database.
例如:对于一个名为测试的程序它在数据库表中的描述为有效
Example : For program named 'Test' it has the description as 'Valid' in the DB Table
例如,当在程序文本作为测试,其相关联的输入程序名称
说明有效应自动填充到说明文本框从纲要文本框失去焦点。
For example, when enter a program name in the program textbox as 'Test', its associated description 'Valid' should be populated automatically to the 'Description' TextBox on losing focus from the 'Program' TextBox.
我怎样才能做到这一点使用asp.net mvc的
How can I achieve this using asp.net mvc
推荐答案
文本框的模糊事件的组合,并使用Ajax调用。
A combination of the textbox blur event and using an ajax call.
$('#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 );
});
});
这篇关于如何调用服务器端方法从一个文本框,asp.net mvc的失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!