How to get ViewData in loaded page, using Asp.net MVC and javascript ?
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.
You don’t need a page load method in ASP.NET MVC. The view data and model is all accessible in the MVC
ViewPagedirectly through theViewDataproperty because theControllerfeeds the view page’sViewData.Say you have a
MyControllerinMyProject/Controllers/MyControllerwith the following action:And in your
Doview inMyProject/Views/My/Do.aspxyou can access the viewdata directly:You can access them in the code-behind files as well because the viewpage inherits from
System.Web.Mvc.ViewPagethat has theViewDataproperty. You can read more about it here.