2014-06-11 37 views
0

因此,我想將URL字符串變成一個名爲「play」的超鏈接,它會將用戶帶到視頻網站鏈接。非靜態字段,方法或屬性需要對象引用

這是我的視頻鏈接。

public class Video 
{ 
    public int Id { get; set; } 
    public string Video_name { get; set; } 
    [Display(Name = "Date added")] 
    [DataType(DataType.Date)] 
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] 
    public Nullable<System.DateTime> Dateadded { get; set; } 
    public string Tag { get; set; } 
    [Display(Name = "Visits")] 
    public int Video_Visits { get; set; } 
    public string URL { get; set; } 
    [Display(Name = "User Name")] 
    public string UserName { get; set; } 
    public string User_Id { get; set; } 
    [Display(Name = "Parental Rating")] 
    public string Parental_rating { get; set; } 
    public Nullable<int> Rating { get; set; } 

    public virtual ApplicationUser User { get; set; } 
    public virtual Rating Rating1 { get; set; } 
    public virtual P_rating P_rating { get; set; } 

} 

在我看來,我添加

<a href="@testing2.Models.Video.URL">play</a> 

,但得到的錯誤:

Error 1 An object reference is required for the non-static field, method, or property 'testing2.Models.Video.URL.get' c:\Users\Setup\Documents\Visual Studio 2013\Projects\testing2\testing2\Views\Video1\Index.cshtml 65 23 testing2

任何人能幫助我們嗎?

+0

這將是很好的,如果你分享你的完整視圖代碼 – malkam

回答

0

將視頻類設置爲查看頁面中的模型。

和您的鏈接將作爲

<a href="@Model.URL">play</a> 
+0

它了。您是指右上角的這段代碼? @model IEnumerable user3695690

+0

仍然有你可以幫助完全相同的錯誤? – user3695690

+0

@model testing2.Models.Video if if only single record。 –

相關問題