D.R.
D.R.

Reputation: 21194

ASP.NET MVC lookup for form field

We've got an ASP.NET MVC-based business form with multiple text boxes to fill out (e.g. a use-case would be "Register person" -> form contains: Name, ..., Father, Mother, ...)

The data entry clerk should not be forced to input father/mother himself, he should be able to search for the person in the system. It is not enough to have some kind of autocomplete field or popup, he should be able to make use of the full-fledged search page we already implemented (Person controller has SearchIndex & SearchPerson action, user has all kind of search options).

The final UI should look like this: Register person form has a button "Select father" which switches the UI to the search page, user searches the person and has the ability to click "Select" on a row in the result table which returns the UI back to the register person form, father-data is now filled into the read-only fields (hidden ID, name & birth date are visible but not editable).

Our problem/question: What is the recommended way to

a) save already entered data in the original form when opening the search form? Is it really necessary to open the search form in a jquery dialog with an IFRAME inside to stay on the same page and not lose the entered data?

b) how to return the selected ID back to the original form and pre-fill the readonly text boxes?

I hope you know what we're trying to achieve, otherwise please comment and I will clarify the question.

Upvotes: 3

Views: 1325

Answers (2)

Codersjunto
Codersjunto

Reputation: 31

I would implement something new and use the Jquery UI Dialog to do the search and and selection. You may/should refactor the existing search system to support different UIs for exactly this purpose or just code a new one.

Upvotes: 1

Raciel R.
Raciel R.

Reputation: 2156

I see two alternatives:

  • You can leverage client side technology. You can either open a modal or populate a div with your search person action result. Once the user finds the father, you can move that data to the appropriated container (read-only text field) and close the search container.
  • You can do all server side. You can always use session to store the data the user typed already, take the user to the search view, and once the user picks the father, you can populate the information stored in session with the father data. The initial form can look on that session variable/object to populate the input fields if they are available.

Notes:

  • You can always combine client/server side technologies as needed.

  • You can use the session, as suggested, but any other storage mechanism for transient data would do the job (key value store: Redis? document db, etc).

Upvotes: 0

Related Questions