html-helper

HTML.ActionLink method

只愿长相守 提交于 2019-11-25 23:29:13
问题 Let\'s say I have a class public class ItemController:Controller { public ActionResult Login(int id) { return View(\"Hi\", id); } } On a page that is not located at the Item folder, where ItemController resides, I want to create a link to the Login method. So which Html.ActionLink method I should use and what parameters should I pass? Specifically, I am looking for the replacement of the method Html.ActionLink(article.Title, new { controller = \"Articles\", action = \"Details\", id = article

Can the ViewBag name be the same as the Model property name in a DropDownList?

半腔热情 提交于 2019-11-25 21:55:36
问题 I am working on an ASP.NET MVC-4 web application. I\'m defining the following inside my action method to build a SelectList : ViewBag.CustomerID = new SelectList(db.CustomerSyncs, \"CustomerID\", \"Name\"); Then I am rendering my DropDownListFor as follow inside my View : @Html.DropDownListFor(model => model.CustomerID, (SelectList)ViewBag.CustomerID, \"please select\") As shown I am naming the ViewBag property to be equal to the Model property name which is CustomerID . From my own testing,