开发者

DropDown list onchange event

开发者 https://www.devze.com 2022-12-20 05:15 出处:网络
HOw can i change content of View开发者_StackOverflow社区Data on drop down list change using javascript in MVC View?Short answer is: you can\'t.

HOw can i change content of View开发者_StackOverflow社区Data on drop down list change using javascript in MVC View?


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.


If I'm not wrong you cannot change from client the server side object that is alive only during page rendering. You could change ViewData object of one page by putting there other data in controller.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号