I create a view from which user can enter value an option from text box and based on the value of option entered by the user, data from the model will be displayed on the view. This works fine if I used 2 views. One for entering the text box option and other for displaying the results. However if I try to to this in the same view, it gives object reference not set error. This is because the model is available only when user enters the text box value and before entering the value itself it will give object reference not set. How can I achieve this using single view?
The code which works fine using 2 views:
Index.cshtml
HelloAction.cshtml
HelloController.cs
Employee.cs
This is the URL using which I run it on local:
http://localhost:57538/Employee/Index
The above code works but how to achieve the same using a single view instead of 2 views?
Thanks