71058

How to call a server side method on losing focus from a textbox, asp.net mvc

Question:

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.

How can I achieve this using asp.net mvc

Answer1:

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

Recommend

  • inserting JSON data from one table to another tables in HIVE
  • MySQL - Order by values in separate table
  • how to access previous view elements in UINavigationController
  • backbone.js collection.get() undefined
  • Configuring WSO2 STATS_DB
  • KeyDown not picking up 'Return' key C#
  • Check for empty textboxes using C# function
  • Ajax Form Submit with submit button
  • c# How to detect and process a .URL file type on DragDrop event
  • update record in database using jdatabase
  • Web service not returning integer data in an object [duplicate]
  • How to save dynamically created textboxes and their values
  • Creating UDF with VSTO in Excel
  • Mvc 3 posting content type application/json, action method arguments loose mapping?
  • (Tcl/Expect) clear screen after exit
  • Failed to find version-tag string. File must be updated
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • Scanner nextInt() and hasNextInt() problems
  • jQuery: How to AJAXify WordPress Search?
  • Trying to get the char code of ENTER key
  • How to add a focus style to an editable ComboBox in WPF
  • Unable to decode certificate at client new X509Certificate2()
  • How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?
  • How can I extract results of aggregate queries in slick?
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • QLPreviewController hide print button in ios6
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Email format validation in mvc3 view
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Uncaught Error: Could not find module `ember-load-initializers`
  • swift auto completion not working in Xcode6-Beta
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • Excel - Autoshape get it's name from cell (value)
  • javascript inside java/jsp code
  • JSON with duplicate key names losing information when parsed
  • Release, debug version and Authorization Google?
  • Jquery - Jquery Wysiwyg return html as a string
  • Is there a mandatory requirement to switch app.yaml?
  • Turn off referential integrity in Derby? is it possible?