开发者

ASP.NET MVC 2 Setting User Control element properties with values in the ViewModel

I'm not entirely sure this is possible, but what I am trying to do is set an element property within a user control to a value passed in via a ViewModel class.

for example, say I have the following ViewModel class

public class myViewModel
{    
    [DisplayName("Image URL")]
    public string URL { get; set; 
}

and then have the following defined on the top of my user control

Inherits="System.Web.Mvc.ViewUserControl<Project.ViewModels.myViewModel>"

why can I not do this to set the src property on an Image tag for example?

<img src="<%Model.URL%>" /开发者_运维知识库>

any help would be great, thanks :)


Did you just miss an = before Model.URL?

e.g. <img src="<%=Model.URL %>" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜