I wrote a sample .net MVC code for my learning. On running the code it should open a text box from which user can enter option1 or option2. If user selects enter option1 it should display the data from first JSON. If the user enters option2, it should display the data from second JSON. It works. The only problem is that the code displays one of the options by default even before the user enters option1 or option2.
Given below is the code for Hello1Controller.cs where hello action is called from the click of button from view code.
Given below is the code for index.cshtml (the view for Hello1Controller). From here on click of button the user selection goes to the controller method named ActionResult
This code is working fine. The only problem is that the code displays one of the options by default even before user enters option1 or option2. I tried to remove index method to solve this but it did not work. How can I remove this default data displayed even before user enters a value?
I understand that Viewbag should be avoided in this example.I will do that correction once I am done correcting the problem I have listed in this post.
posted 3 weeks ago
I will remove the view bag and replace it with returning model object from the controller. I think this should solve the current problem.
Would you like to try a free sample? Today we are featuring tiny ads: