FAQ Database Discussion Community

Get Column title in View

MVC5 did a great job on automatically creating the View page (Razor). It currently displays my list of Students for example with table heading like this: <th> @*@Html.ActionLink("", "Index", new { sortOrder = ViewBag.NameSortParm })*@ @Html.DisplayNameFor(model => model.LastName) </th> Now. DisplayNameFor take a Lambda Expression as its parameter. However, I...

ActionLink (LinkText,Action,ControlName,AreaName,RoutesValue,html attribute)

A bottom'd like code samples ActionLink (LinkText,Action,ControlName,AreaName,RoutesValue,html attribute) I looked at the sites do not have all of these together Thanks

Hide ActionLinks based on user roles without exposing roles in view

I use the AuthorizeAttribute and roles (Identity). I want to hide ActionLinks based on user roles. I found solutions with HtmlHelpers like this. But I really don't like those solutions because the view must know about the required roles. This means the roles are defined twice: in the controller and...

MVC4 - ActionLink to either Create() or, if already existing, Edit(Id)

I would like an action link that says "set user default". There's a possibility the database does not already have the UserDetails stored for the user who clicks the link. If this is the case, I would like to direct the user to the Create view when they can save...

MVC Routes, adding a filter to existing page

I have a route: context.MapRoute( "ISPCCodeSearch_default", "OnlineOrder/{controller}/ISPCCodeSearch/{ISPC}", new { area = "OnlineOrder", controller = "Home", action = "ISPCCodeSearch", ISPC = UrlParameter.Optional, }); that brings up a number of products by a product code eg, OnlineOrder/Home/ISPCCodeSearch/11011/ I want to further filter this by brand by clicking on a filter link on...

Click actionlink on view, controller checks condition, returns JSON, jQuery Ajax doesn't work

Click ActionLink on view, controller checks condition, returns JSON, JQuery Ajax doesn't work. Click the "Delete" ActionLink, "Delete" controller if customer's "Orders" property is null, if not null, a message will be popped up. If null, process to "Delete" view. Here are the codes: 1, on the view, the @Html...

How can I return a model with an ActionLink?

I'm trying to get a model in a view and pass it to another controller but the model is null when passed to the other controller. Controller - Here I send the model to render in my view: [HttpPost] public PartialViewResult Index(ReportesTabularesViewModel ModeloInput) { GetDatosTabularReportInput input = new GetDatosTabularReportInput {...

Use Ajax actionlink for entire table row

At the moment I am using the following code to display information in a partial view below my table - @foreach (var item in Model) { <tr> <td> @Ajax.ActionLink( item.FirstName, "DisplayApplication", new { ID = item.ColleagueID }, new AjaxOptions { UpdateTargetId = "Application" } ) </td> <td> ... </td> <td>...

Remove style from an actionlink

I have an actionlink as such, <td> @Ajax.ActionLink( item.FirstName, "DisplayApplication", new { ID = item.ColleagueID }, new AjaxOptions { UpdateTargetId = "Application" } ) </td> I want this to appear just as normal text does on the rest of my website without the normal styling that a link will have,...

Is possible to insert HTML.Actionlink inside LI?

I'm trying to insert a @HTML.ActionLink element inside a li element using the following code: var ul = document.getElementById('container'); var enlace = '@Html.ActionLink("Details", "Details", "Elements", new { id = "5" }, null)'; var li = document.createElement('li'); li.appendChild(document.createTextNode('My title')); li.appendChild(document.createElement('br')); /////////////////////////////////////////////// li.appendChild(document.createElement(enlace)); /////////////////////////////////////////////// ul.appendChild(li); Is it...

ASP.NET MVC4 - Different routing for 2 controllers with actionLinks

Okay, I've got this case where I have two controllers: HomeController MathController I want the routing for my HomeController to stay as default:{controller}/{action}/{id}. But I want to access the actions in the MathController with http://myurl/Task/Math/{action}. So what I've done is to write my RouteConfig like this: routes.MapRoute( name: "Math", url:...