我有這個類「Firma」,它有3個屬性,所有字符串。但我想要FirmaUrl屬性是一個URL?這應該是什麼類型,我如何把它作爲參數在構造函數中?ASP .NET如何引用來自我的域的HTML鏈接?
代碼:
public class Firma
{
public int FirmaId { get; set; }
public string Naam{ get; set; }
public string FirmaUrl { get; set; }
public string Contactemail { get; set; }
public Firma()
{
}
public Firma(string naam, string firmaurl, string contactemail)
{
Naam = naam;
FirmaUrl = firmaurl;
Contactemail = contactemail;
}
}
初始化此:
Firma Hogent = new Firma("Hogent", "www.hogent.be", "[email protected]");
的觀點:
<dt>
@Html.DisplayNameFor(model => model.Firma.Naam)
</dt>
<dd>
@Html.DisplayFor(model => model.Firma.Naam)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Firma.Contactemail)
</dt>
<dd>
@Html.DisplayFor(model => model.Firma.Contactemail)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Firma.FirmaUrl)
</dt>
<dd>
@Html.DisplayFor(model => model.Firma.FirmaUrl)
</dd>
預先感謝您!
URL將是一個字符串。你已經有了一個字符串,它已經在構造函數中。究竟是什麼問題? – David
我希望它在我的視圖中顯示爲可點擊的鏈接。但現在我意識到我應該只是使用基本的HTML標記..我是一個愚蠢的,總是過於複雜的事情.. –