html.actionlink

ASP.NET MVC ActionLink renders erroneously

元气小坏坏 提交于 2019-12-06 15:43:18
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 markup: <a href="/eagle/Intervention/Edit_Inv?Count=1&Keys=System.Collections.Generic.Dictionary%602

Pass List<int> from actionlink to controller method

可紊 提交于 2019-12-06 11:11:08
问题 In my controller I have this: ViewBag.lstIWantToSend= lstApps.Select(x => x.ID).ToList(); // creates a List<int> and is being populated correctly I want to pass that list to another controller.. so in my view I have: @Html.ActionLink(count, "ActionName", new { lstApps = ViewBag.lstIWantToSend }, null) Method in Controller: public ActionResult ActionName(List<int> lstApps) // lstApps is always null Is there a way to send a list of ints as a route value to a controller method? 回答1: its not

Get current action and controller and use it as a variable in an Html.ActionLink?

ぃ、小莉子 提交于 2019-12-05 01:27:59
I need to be able to dynamically retrieve the current action and controller name of whatever page you're on, and actually use them to create a new HTML.ActionLink that links to the same action and controller name, but in a different area. So I guess I need to retrieve the current action and controller name as variables to use in building a new HTML.ActionLink. So, if I'm on the www.site.com/about page, I need to have a link dynamically generated to the www.site.com/es/about page. I've basically built a spanish translated version of my site in a separate area folder (with the same named

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

笑着哭i 提交于 2019-12-05 00:06:53
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", new { controller = "Page", slug = "page-slug" }) or better yet, <a href="@Url.Action("ViewPage", new

Pass List<int> from actionlink to controller method

柔情痞子 提交于 2019-12-04 17:19:24
In my controller I have this: ViewBag.lstIWantToSend= lstApps.Select(x => x.ID).ToList(); // creates a List<int> and is being populated correctly I want to pass that list to another controller.. so in my view I have: @Html.ActionLink(count, "ActionName", new { lstApps = ViewBag.lstIWantToSend }, null) Method in Controller: public ActionResult ActionName(List<int> lstApps) // lstApps is always null Is there a way to send a list of ints as a route value to a controller method? its not possible directly but you can do it with Json if i have List<int> ViewBag.lstIWantToSend= new List<int> {1, 2, 3

How to use MVC 3 @Html.ActionLink inside c# code

﹥>﹥吖頭↗ 提交于 2019-12-04 02:48:41
问题 I want to call the @Html.ActionLink method inside a c# function to return a string with a link on it. Something like this: string a = "Email is locked, click " + @Html.ActionLink("here to unlock.", "unlock") ; 回答1: Assuming that you want to accomplish this in your controller, there are several hoops to jump through. You must instantiate a ViewDataDictionary and a TempDataDictionary . Then you need to take the ControllerContext and create an IView . Finally, you are ready to create your

on html.actionlink click go to previous page

孤者浪人 提交于 2019-12-02 20:06:56
Currently in a link Customer/businessunit/RepresentativeDetails?RepresentativeId=cd3a7263-78f7-41bd-9eb0-12b30bc1059a I have following code for view @Html.ActionLink("Back to List", "Index") which takes me to this link customer/businessunit/index but rather that going to index page I want to go to previous page when the actionlink is clicked, which is Customer/businessunit/BusinessUnitDetails/c4a86253-a287-441e-b83d-71fbb6a588bc How do I create an actionlink that directs me to previous page? something like @Html.ActionLink("Back to Details", //go to previous page) Unless you're tracking what

How to use MVC 3 @Html.ActionLink inside c# code

痴心易碎 提交于 2019-12-01 15:06:31
I want to call the @Html.ActionLink method inside a c# function to return a string with a link on it. Something like this: string a = "Email is locked, click " + @Html.ActionLink("here to unlock.", "unlock") ; Assuming that you want to accomplish this in your controller, there are several hoops to jump through. You must instantiate a ViewDataDictionary and a TempDataDictionary . Then you need to take the ControllerContext and create an IView . Finally, you are ready to create your HtmlHelper using all of these elements (plus your RouteCollection ). Once you have done all of this, you can use

How to use CSS on an Html.ActionLink in C#

此生再无相见时 提交于 2019-11-30 17:36:47
I tried this code <%: Html.ActionLink("Home", "Index", "Home", new { @class = "NavLink" })%> and it links to the css so that I can style the link, but it changes the link to have a different URL that is not to my controller like it is without the new { @class = "NavLink" } . Is there any way to let me style these links without ruining my URLs so they go to the correct pages? Thanks! Make sure you are using the proper overload : <%: Html.ActionLink("Home", "Index", "Home", null, new { @class = "NavLink" })%> ^ ^ routeValues htmlAttributes Method Actionlink have some overloading. If you want to

Route to different View(use @Html.ActionLink and ng-view in View) in Asp.Net MVC with AngularJS, ng-view only work one time, location url strange

為{幸葍}努か 提交于 2019-11-30 16:55:48
In my case, I need use @Html.ActionLink to Route to different View with AngularJS.In each view1/index.cshtml in asp.net has <div ng-view></div> that will load its html template. the following link image is my project structure: click My problem is: it only route success first time.I think it cause wrong location url. Views/Share/_Layout.cshtml: <ul> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("Device Management", "Index", "DeviceManagement")</li> </ul> Views/Home/index.cshtml: @{ ViewBag.Title = "Home Page"; ViewBag.InitModule = "homeIndex"; } @section Scripts {