HOw can i change content of ViewData on drop down list change using javascript in MVC View?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short answer is: you can’t.
Even if you could, nothing would happen Because you’d need to render your view with the new ViewData.
Javascript runs client side. That means, the user’s computer.
ViewData is a server side collection. It is a data transfer object between your controller and view, which stays on your server.
You need to change the way you think. You can either make the change you want with javascript on client’s comptuer when drop down changes, or you can post the value in drop down list and render the view with the new data, and send back to client.