Handout 2

Handout 2 - IS 3920 - Application Development II Handout #2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
IS 3920 - Application Development II Handout #2 The Basics of MVC Passing data to a View through ViewData and Inline Code ViewData is a property of the ViewPage class It takes a field name and associates an object value to that name ViewData("Message") = "Hello There!" Once set in a Controller function, it can be used in a View with Inline Code as follows: <h2><%: ViewData("Message") %></h2> View Functions can pass data to other Functions using Session Variables: Function Brochure() As ActionResult Session(“Name") = “John Smith" Session("Email") = "JohnSmith@gmail.com" Session("Phone") = "555-123-4567" Return View() End Function There are many HTMLHelper functions from the HTML Helper class: http://msdn.microsoft.com/en-us/library/system.web.mvc.htmlhelper.aspx This Helper function provides a link to the standard CSS file: <%= Html.Css("~/Content/styles.css") %> This Helper function creates an Image tag with its Alt attribute: <%= Html.Image("~/folder/img.gif", "My Alt Text")
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Handout 2 - IS 3920 - Application Development II Handout #2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online