ASP.NET MVC: How to Display custom object properties in View page

Posted by Shyju on Stack Overflow See other posts from Stack Overflow or by Shyju
Published on 2010-06-07T17:33:02Z Indexed on 2010/06/07 17:42 UTC
Read the original article Hit count: 262

Filed under:
|

I am trying to add ASP.NET MVC features(Especially Routing) to my already existing ASP.NET Web application.I added a Controlled and View (an asp.net page) .Now i want to know how can i display the details of object of my custom class( Ex : User) in the view ? Can assign the object in ViewData collection and render it in the view ? Hows that ? I already have a Datalayer (in ADO.NET) which is running for the the current ASP.NET web app.So i want to use that.

I tried this in my controller

public ActionResult Index()
    {
        BusinessObject.User objUser = new BusinessObject.User();
        objUser.EmailId = "[email protected]";
        objUser.ProfileTitle = "Web developer with 6 yrs expereince";

        ViewData["objUser"] = objUser;
        ViewData["Message"] = "This is ASP.NET MVC!";

        return View();
    }

How can i use this in the view page to display the user details ?

Thanks in advance

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about controller