question

ngJimmy-8394 avatar image
0 Votes"
ngJimmy-8394 asked DuaneArnold-0443 answered

Dynamic labels in view that display information queried from another model

Hi, I am trying to make my view to include labels that update themselves when other input fields on the page have been updated. EF6 is used for mapping.

When the name and date fields of the page have been updated, I want a label to display data from another model. The data can be obtained by querying the database using the current name and date the user has just inputted. A label should update itself when either of the inputted date or name is changed. How can I do this?

I am trying to make my view to include labels that update themselves when other input fields on the page have been updated.

When the name and date fields of the page have been updated, I want a label to display data from another model. The data can be obtained by querying the database using the current name and date the user has just inputted. A label should update itself when either of the inputted date or name is changed. How can I do this?

I would like to do the filtering with jQuery Ajax, how should I code the controller and view? Thanks in advance.
Here is the models, controller and view I use 6334662.aspx


dotnet-aspnet-core-generaldotnet-aspnet-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered

You could use Ajax for this that is doing a Get to a action method on a MVC controller. The controller action method goes to the database and Jason data is returned to the view where you can use jquery to update a HTML control data attribute.

I think you wold have to call a Javascript method that is going to make the AJAX call and use Jquery to update the view, which could be triggered on a Onblur() event for a control as an example.

You should be able to find examples that do this.

Or maybe do a submi with flag on a post back to the controller, the flag makes the controller execute a method to go get the data, the viewmodel is updated and the controller method shows the view again.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.