<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>p2p.wrox.com Forums - BOOK:  Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9</title>
		<link>http://p2p.wrox.com</link>
		<description>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 
Read more about Professional ASP.NET MVC 1.0 or buy the book from your favorite retailer</description>
		<language>en</language>
		<lastBuildDate>Sat, 21 Nov 2009 22:37:31 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://p2p.wrox.com/images/misc/rss.jpg</url>
			<title>p2p.wrox.com Forums - BOOK:  Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9</title>
			<link>http://p2p.wrox.com</link>
		</image>
		<item>
			<title>Getting started - Chapter 5</title>
			<link>http://p2p.wrox.com/book-professional-asp-net-mvc-1-0-isbn-978-0-470-38461-9/77052-getting-started-chapter-5-a.html</link>
			<pubDate>Mon, 16 Nov 2009 20:03:48 GMT</pubDate>
			<description><![CDATA[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...]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
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.<br />
<br />
The book says:<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="6" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				&quot;Define a simple class here named Product&quot;
			
			<hr />
		</td>
	</tr>
	</table>
</div>. Um, where are we currently? Never mind, I have created the Product class in a folder in the root called 'Objects' for now.<br />
<br />
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)<br />
<br />
My view code is:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><span style="color:#000080">&lt;%@ Page Title=<span style="color:#0000FF">&quot;&quot;</span> Language=<span style="color:#0000FF">&quot;C#&quot;</span> MasterPageFile=<span style="color:#0000FF">&quot;~/Views/Shared/Site.Master&quot;</span> Inherits=<span style="color:#0000FF">&quot;System.Web.Mvc.ViewPage&lt;Product&gt;&quot;</span> %&gt;</span><br />
<span style="color:#000080">&lt;%@ Import Namespace=<span style="color:#0000FF">&quot;MVC_App_WroxChapter3.Objects&quot;</span>%&gt;</span><br />
<br />
<span style="color:#000080">&lt;asp:Content ID=<span style="color:#0000FF">&quot;Content1&quot;</span> ContentPlaceHolderID=<span style="color:#0000FF">&quot;head&quot;</span> runat=<span style="color:#0000FF">&quot;server&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000080">&lt;title&gt;</span>Edit<span style="color:#000080">&lt;/title&gt;</span><br />
<span style="color:#000080">&lt;/asp:Content&gt;</span><br />
<br />
<span style="color:#000080">&lt;asp:Content ID=<span style="color:#0000FF">&quot;Content2&quot;</span> ContentPlaceHolderID=<span style="color:#0000FF">&quot;MainContent&quot;</span> runat=<span style="color:#0000FF">&quot;server&quot;</span>&gt;</span><br />
<br />
&nbsp; &nbsp; <span style="color:#000080">&lt;h2&gt;</span>Edit<span style="color:#000080">&lt;/h2&gt;</span><br />
&nbsp; &nbsp; <span style="color:#000080">&lt;p&gt;</span><span style="color:#000080">&lt;%= Html.Encode(ViewData&#91;&quot;Message&quot;&#93;) %&gt;</span><span style="color:#000080">&lt;/p&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color:#000080">&lt;% using (Html.BeginForm())<br />
&nbsp; &nbsp; &nbsp;  { %&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <span style="color:#000080">&lt;p&gt;</span>Name: <span style="color:#000080">&lt;%= Html.TextBox(&quot;ProductName&quot;) %&gt;</span> <span style="color:#000080">&lt;%= Html.ValidationMessage(&quot;ProductName&quot;) %&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <span style="color:#000080">&lt;/p&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <span style="color:#000080">&lt;p&gt;</span>Price: £ <span style="color:#000080">&lt;%= Html.TextBox(&quot;UnitPrice&quot;) %&gt;</span> <span style="color:#000080">&lt;%= Html.ValidationMessage(&quot;UnitPrice&quot;) %&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <span style="color:#000080">&lt;/p&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <span style="color:#FF8000">&lt;input type=<span style="color:#0000FF">&quot;submit&quot;</span> /&gt;</span><br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; <span style="color:#000080">&lt;% } %&gt;</span><br />
<br />
<span style="color:#000080">&lt;/asp:Content&gt;</span></code><hr />
</div> <br />
<b>Edit:</b><br />
<br />
OK so if I return the view as such:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">return View(product);</code><hr />
</div> then the form fields are completed.<br />
<br />
But what is <div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">HTML Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">ViewData&#91;&quot;product&quot;&#93; = product;</code><hr />
</div> supposed to do?<br />
<br />
<br />
Thanks,<br />
<br />
Noob!</div>

]]></content:encoded>
			<category domain="http://p2p.wrox.com/book-professional-asp-net-mvc-1-0-isbn-978-0-470-38461-9-490/">BOOK:  Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9</category>
			<dc:creator>eno</dc:creator>
			<guid isPermaLink="true">http://p2p.wrox.com/book-professional-asp-net-mvc-1-0-isbn-978-0-470-38461-9/77052-getting-started-chapter-5-a.html</guid>
		</item>
	</channel>
</rss>
