FluentHtml help (not helper)

13 views
Skip to first unread message

Nick Kirkes

unread,
Apr 27, 2009, 10:17:38 PM4/27/09
to mvccontrib-discuss
So, I feel completely stupid and am hoping someone with some patience
will point me in the right direction.

I have a demo app I'm using to get broader experience with
MvcContrib. I'm attempting to utilize the FluentHtml library in my
Views. I have strongly-typed views that are inheriting from
ModelViewPage<T>. I have the MvcContrib and MvcContrib.FluentHtml
assemblies referenced in my web app. I'm using the helpers similarly
to Tim's blog posts (below for reference, but I can't for the life of
me figure out why I'm getting compiler errors and no intellisense for
the methods I should be able to call.

I just want to be able to explore the FluentHtml library and see what
it's all about.

Here's code from a sample view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/
Site.Master"
Inherits="MvcContrib.FluentHtml.ModelViewPage<DemoApp.Core.Employee>"
%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent"
runat="server">
New
</asp:Content>

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

<h2>New</h2>
<% using (Html.BeginForm("Create", "Employees")) { %>

<p>Name: <%= this.TextBox(x => x.Name) %></p> <!-- THIS BREAKS -->

<p>Street Address: <%= Html.TextBox("StreetAddress") %></p> <!--
THESE ARE JUST FINE; Standard Mvc extensions -->
<p>City: <%= Html.TextBox("City") %></p>
<p>State: <%= Html.TextBox("State") %></p>
<p>Zip Code: <%= Html.TextBox("Zip") %></p>
<p>Email: <%= Html.TextBox("Email") %></p>
<p>Home Phone: <%= Html.TextBox("HomePhone") %></p>
<p>Work Phone: <%= Html.TextBox("WorkPhone") %></p>
<p>Cell Phone: <%= Html.TextBox("CellPhone") %></p>

<p>Role: <%= Html.DropDownList("AvailableRoles")%></p>

<p><input type="submit" value="Save Employee" /></p>

<% } %>
</asp:Content>

Nick Kirkes

unread,
Apr 27, 2009, 10:30:35 PM4/27/09
to mvccontrib-discuss
Answered my own question: I needed the following in my web.config
namespaces block:

<add namespace="Microsoft.Web.Mvc"/>
<add namespace="MvcContrib.FluentHtml"/>

The addition of the Microsoft assembly came out of nowhere for me. Is
that documented somewhere that I can link to for future reference?
Maybe it's a framework issue I didn't recognize?

Nick

Tim Scott

unread,
Apr 27, 2009, 10:31:06 PM4/27/09
to mvccontri...@googlegroups.com
Try this. In web.config, add this:

<add namespace="MvcContrib.FluentHtml"/>

...in <system.web><pages><namespaces>.

If that does not work, please post the error you are getting.

Nick Kirkes

unread,
Apr 27, 2009, 11:29:37 PM4/27/09
to mvccontrib-discuss
Hey Tim, thanks for the reply. I beat you to it (see my previous
reply), but I did have to add a reference to Microsoft.Web.Mvc which
threw me. Is that a framework requirement for adding extensions or is
it something inherent to MvcContrib?

Thanks again,

Nick

On Apr 27, 8:31 pm, Tim Scott <tsc...@lunaversesoftware.com> wrote:
> Try this.  In web.config, add this:
>
> <add namespace="MvcContrib.FluentHtml"/>
>
> ...in <system.web><pages><namespaces>.
>
> If that does not work, please post the error you are getting.
>

Tim Scott

unread,
Apr 27, 2009, 11:39:54 PM4/27/09
to mvccontri...@googlegroups.com
In markup files, as in C# classes, you need namespaces to refer to classes
without fully qualified names, or to use extension methods (as with your
issue). You can do that in each markup file that needs it, like so:

<%@ Import Namespace="MvcContrib.FluentHtml"%>

Or you can do it globally in the web.config namespaces section.

Tim

Nick Kirkes

unread,
Apr 27, 2009, 11:51:54 PM4/27/09
to mvccontrib-discuss
Sorry, I was referring to the addition of Microsoft.Web.Mvc. Is that
a dependency of the FluentHtml assembly? I wasn't able to get
intellisense or a successful build until I added a reference to that
specific namespace.

On Apr 27, 9:39 pm, Tim Scott <tsc...@lunaversesoftware.com> wrote:
> In markup files, as in C# classes, you need namespaces to refer to classes
> without fully qualified names, or to use extension methods (as with your
> issue).  You can do that in each markup file that needs it, like so:
>
> <%@ Import Namespace="MvcContrib.FluentHtml"%>
>
> Or you can do it globally in the web.config namespaces section.
>
> Tim
>

Tim Scott

unread,
Apr 28, 2009, 10:49:08 AM4/28/09
to mvccontri...@googlegroups.com
No FluentHtml does not depend on Microsoft.Web.Mvc. That is the "futures"
assembly for MVC. That has some HtmlHelper extensions in it.
Reply all
Reply to author
Forward
0 new messages