html.actionlink

Hide or Disable MVC3 ActionLinks depending on cell value

馋奶兔 提交于 2019-12-11 23:43:05
问题 MVC3 has created the following table for me @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Author) </td> <td> @Html.DisplayFor(modelItem => item.Comment) </td> <td> @Html.ActionLink("Edit", "Edit", new { id=item.UserCommentID }) | @Html.ActionLink("Details", "Details", new { id=item.UserCommentID }) | @Html.ActionLink("Delete", "Delete", new { id=item.UserCommentID }) </td> </tr> } I am sure everyone has seen this sort of thing a million times before. Does anyone

Pass @Html.DropDownList selection using @Html.ActionLink with ViewModel to Controller

僤鯓⒐⒋嵵緔 提交于 2019-12-11 11:00:55
问题 I've been reading through posts for two days regarding this, and still have not figured out the answer. I want to capture the DropDownList selection within my ModelView, pass this to a @Html.ActionLink, which will send it back to a specific Action within the Controller. My ViewModel: public class ViewModelShipments { public ViewModelShipments() { tblShipments = new tblShipments(); } public tblShipments tblShipments; public IEnumerable<SelectListItem> ShipmentIDsList; public string

Passing model in collection to actionlink

天大地大妈咪最大 提交于 2019-12-11 10:37:26
问题 I feel like this is a pretty basic question. What I am trying to achieve is display a collection of objects as links. When I click on a link, I want to be taken to that specific object's details. I can display a collection of item links on the index view, but when I click an item link, I can display the SingleProductView, but cannot display that specific item's variables there. Is it possible to pass the specific item to the view through the html.actionlink? Or, is it possible to pass that

ActionLink is showing query string instead of URL parameters

倖福魔咒の 提交于 2019-12-11 06:07:22
问题 My question is very similar other questions. When using an ActionLink in MVC .Net 4.5, I am getting a query string for one parameter, instead of just a URL path. I tried the solution HERE, but it did not work. CODE- Inside RouteConfig.cs - routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( name: "MyControllerRoute", url: "{controller}/{action}/{id}/{description}", defaults

How to use/pass hidden field value in ActionLink

血红的双手。 提交于 2019-12-11 00:52:05
问题 I have problem passing hidden field value in actionlink parameter: productView: @Html.ActionLink("ProductCompare", "ProductCompare", new { ProductIds= **hdnSelectedProductId**) @Html.Hidden("hdnSelectedProductId") Controller Action: public ActionResult ProductCompare(string ProductIds) { return View(); } When user select any product i keep putting product ids in hdnSelectedProductId using javascript. Now when user click on ProductCompare link i want to pass this hidden field value to

Using Html.ActionLink and Url.Action(…) from inside Controller

怎甘沉沦 提交于 2019-12-10 02:02:21
问题 I want to write an HtmlHelper to render an ActionLink with pre-set values, eg. <%=Html.PageLink("Page 1", "page-slug");%> where PageLink is a function that calls ActionLink with a known Action and Controller, eg. "Index" and "Page". Since HtmlHelper and UrlHelper do not exist inside a Controller or class, how do I get the relative URL to an action from inside a class? Update: Given the additional three years of accrued experience I have now, here's my advice: just use Html.ActionLink("My Link

How To Send ActionLink Parameters With routevalue in asp.net mvc 5 to controller with jquery

有些话、适合烂在心里 提交于 2019-12-08 07:32:29
@Html.ActionLink("mor info","CityInfo",new{cityid = --getvalue()--},new {@class = "mbtn" }) I want to get Value Selected In Dropdownlist CityId With Jquery But I Can't Use JQuery Function in RouteValue How to use JQuery Function in Routevalue? or How to Get selected CityId and Send To Action in Controller? For example You can achieve this with jQuery function on dropdown value change event and setting element href attribute. If You want, change <select /> to @Html.DropDownListFor() or @Html.DropDownList() <script type="text/javascript"> $(document).ready(function () { $('.myClass').change

To avoid auto generated Query string value in ActionLink

喜你入骨 提交于 2019-12-08 05:42:23
问题 I was trying to add a css class to anchor but while rendering to html the href attribute has query string with value 4. The controller name "Home" length is appended to href link. If I remove the css class it's working fine. Ho to avoid the autogenerated query string value. Razor Code: @Html.ActionLink("Create Application", "CreateApplication", "Home", new {@class="link"}); Rendered html is : <a href="/Account/CreateApplication?Length=4" class="link">Create Application</a> 回答1: If you want to

How To Send ActionLink Parameters With routevalue in asp.net mvc 5 to controller with jquery

。_饼干妹妹 提交于 2019-12-08 05:17:27
问题 @Html.ActionLink("mor info","CityInfo",new{cityid = --getvalue()--},new {@class = "mbtn" }) I want to get Value Selected In Dropdownlist CityId With Jquery But I Can't Use JQuery Function in RouteValue How to use JQuery Function in Routevalue? or How to Get selected CityId and Send To Action in Controller? 回答1: For example You can achieve this with jQuery function on dropdown value change event and setting element href attribute. If You want, change <select /> to @Html.DropDownListFor() or

ASP.NET MVC ActionLink renders erroneously

余生颓废 提交于 2019-12-08 03:36:28
问题 SO community I have the following issue: If i render an ActionLink like this: @Html.ActionLink(titleText, Title.Href.TargetAction, Title.Href.TargetController, Title.Href.TargetRouteValues, null) the rendered element is: <a href="/eagle/Intervention/Edit_Inv?ID_INV=53165"> 19/ 2013</a> but if i add an object as HTMLAttributes like this: @Html.ActionLink(titleText, Title.Href.TargetAction, Title.Href.TargetController, Title.Href.TargetRouteValues, new {target="_blank"}) i get the following