views:

53

answers:

3

In views/home/index.aspx:

<% this.Html.DisplayFor(m => m.NewLink); %>

index.aspx is strongly typed to HomeViewModel.cs, which has the property used above right here:

public Link NewLink { get; private set; }
(in constructor), this.NewLink = new Link();

In views/home/displaytemplates/addform.ascx:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<urlme.Model.Link>" %>
this should show up on index.aspx

When I run it, nothing shows up at all. I know that I can go a such a way that I create a separate view model for the partial to be bound to, then just name the partial view AddLinkViewModel.ascx, then it should work, but that's too much code and too long of a filename ;) Do I need to use a UIHint?? Hopefully not, as that feels hack-ish. Thanks!

A: 

try naming the partial views/home/displaytemplates/link.ascx

Clicktricity
didn't work :/ thanks tho
Ian Davis
A: 

Looks like you forgot the = at the start of the tag so the display template is being parsed just not being written into the stream.

<%=this.Html.DisplayFor(m => m.NewLink); %>

Chao
A: 

Try Html.DisplayForModel instead

<%= Html.DisplayForModel("addform", Model.NewLink) %> 
byte
Thanks, but, trying to avoid the hard coded strings...
Ian Davis