I work with c# MVC3 & razor, Entity Framework and Linq.
I have a form, with two field, the first one Client ID and the second one Store Name.
I would like, when the user enter the ID, then my StoreName field fill automatically… The data would come from a database where this two data are stored.
You could use AJAX. So setup a controller action taking a client id as parameter and that would query your database and return the corresponding store name as JSON result. Then subscribe to the
.blurevent of the text input containing the store id and send an AJAX call to the controller action to fill the second input field.Yeah, I know, meaningless jibber-jabber, gimme the codez.
Here:
Now assuming the following view:
in a separate javascript file you could subscribe to the
.blurevent of the first textbox, and trigger the AJAX request to the controller sending it the client id that was entered by the user. In the success callback you would update the second textfield with the result of the AJAX call: