Wrox Programmer Forums
|
BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9
This is the forum to discuss the Wrox book Professional ASP.NET MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie; ISBN: 978-0-470-38461-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2009, 04:03 PM
eno eno is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting started - Chapter 5

Hi all,

I feel like a complete idiot asking this but on page 244 (Chapter 5: Controllers) I can't get the code to work correctly. I am a complete beginner to MVC but have been using ASP and Webforms for years.

The book says:
Quote:
"Define a simple class here named Product"
. Um, where are we currently? Never mind, I have created the Product class in a folder in the root called 'Objects' for now.

The book then goes on to describe the Controller and View. I have the view but the texboxes are not populating with the product instance. What have I done wrong? (When I created the View I did not create a strongly typed view)

My view code is:

HTML Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Product>" %>
<%@ Import Namespace="MVC_App_WroxChapter3.Objects"%>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<title>Edit</title>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Edit</h2>
    <p><%= Html.Encode(ViewData["Message"]) %></p>
    
    <% using (Html.BeginForm())
       { %>
       <p>Name: <%= Html.TextBox("ProductName") %> <%= Html.ValidationMessage("ProductName") %>
       </p>
       
       <p>Price: £ <%= Html.TextBox("UnitPrice") %> <%= Html.ValidationMessage("UnitPrice") %>
       </p>
       
       <input type="submit" />
       
    <% } %>

</asp:Content>

Edit:

OK so if I return the view as such:

HTML Code:
return View(product);
then the form fields are completed.

But what is
HTML Code:
ViewData["product"] = product;
supposed to do?


Thanks,

Noob!

Last edited by eno; November 16th, 2009 at 04:34 PM..
 
Old November 17th, 2009, 04:07 PM
eno eno is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anyone? Surely this is an issue of something missing?

Can someone please set this page up working and send the code? (Seeing as the Wrox 'Code download' consists of completely useless randomly numbered text files)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 - Getting Started - Adding Connection roscoe BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 6 November 6th, 2006 05:03 AM
Getting Started st3ve Javascript How-To 1 February 3rd, 2005 08:49 PM
Getting started with chapter 12 Indigo11 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 2nd, 2004 06:37 PM
Help Getting Started Bob Bedell JSP Basics 1 July 15th, 2003 11:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.