2013-03-01 51 views

回答

4

你應該在你的控制器中做這個邏輯,並且有一個名爲FullName的屬性。

例如:

ViewModel model = new ViewModel(); 
model.Person = GetPerson(); 
model.FullName = model.Person.FirstName + " " + model.Person.LastName; 
return View(model); 

後來乾脆:

@Html.TextBoxFor(m=>m.FullName) 

如果你想採取了一步,FullName可能是Person屬性,並進行邏輯在GetPerson()方法。

+0

行..謝謝...但我們不能這樣做,沒有添加新的屬性..對不對? – 2013-03-01 11:17:38

+0

@hetalgala這是正確的,你需要添加一個新的屬性到你的視圖模型 – Curt 2013-03-01 11:18:19

+0

ok ..fine會做到這一點 – 2013-03-01 12:37:52

相關問題