html.actionlink

on html.actionlink click go to previous page

放肆的年华 提交于 2020-01-11 17:09:28
问题 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?

In html attributes setting disabled = “disabled” not working

给你一囗甜甜゛ 提交于 2020-01-06 17:00:02
问题 @Html.ActionLink(" ", "Edit", new { id = item.UserId }, new { title = "User is not editable" , @class = "edit_btn", disabled = "disabled"}) I want to disable ActionLink by setting html attribute disabled ="disabled", but its not working. I am able to get class and title attributes but actionLink is not getting disabled. Can anyone help.. Where I am doing wrong. 回答1: The disabled attribute doesn't work in anchor tags. MVC renders what you expect, disabled="disabled" , but browsers just ignore

ASP.NET MVC : capture result of download prompt

谁说胖子不能爱 提交于 2020-01-05 04:23:15
问题 I have a bit of code that makes a file available and prompts user to open/download/cancel . I would like to take an action if the file is opened or downloaded , but not if canceled . This is the download line, from the controller : return File(fileAsBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName); I guess my question is, how do I capture a return value from this action? Would I see the result in the controller or in the view that calls it? I'm a struggling newbie. Don't

Asp.Net mvc 5 - How can I pass a complex object as route value in Html.ActionLink() so default model binder can map it?

一世执手 提交于 2019-12-28 06:31:25
问题 I have an object containing searching, sorting and paging parameters as well as an id of a record to be edited. I'd like to pass this object into Html.ActionLink() as a route value object, so that the resulting query string will be correctly mapped by the default model binder into the Edit action's parameter, which is an EditViewModel. The idea is that after the Edit action completes, it can redirect back to the Index and maintain the same paging/sorting position, in the same data set, and

Asp.Net mvc 5 - How can I pass a complex object as route value in Html.ActionLink() so default model binder can map it?

≡放荡痞女 提交于 2019-12-28 06:31:07
问题 I have an object containing searching, sorting and paging parameters as well as an id of a record to be edited. I'd like to pass this object into Html.ActionLink() as a route value object, so that the resulting query string will be correctly mapped by the default model binder into the Edit action's parameter, which is an EditViewModel. The idea is that after the Edit action completes, it can redirect back to the Index and maintain the same paging/sorting position, in the same data set, and

pass object through @Html.ActionLink with click

蓝咒 提交于 2019-12-24 09:05:20
问题 What I'm trying to do is pass the item that was clicked to the controller for editing but the only thing I can pass to the controller is a string. view: foreach (MenuItemViewModel menuitem in category.MenuItemList) { <span class="MenuItemTitel"> @if (IsAdmin) { <span class="AdminSpan"> @Html.ActionLink("Edit", "EditPage", "Admin", new { name = menuitem.Title }) </span> } @menuitem.Title </span> } Controller: public ActionResult EditPage(MenuItemViewModel MenuItem) {} 回答1: The @Html.ActionLink

How can I link to the root of the site with Html.ActionLink?

被刻印的时光 ゝ 提交于 2019-12-22 13:54:49
问题 I have this ActionLink to login: @Html.ActionLink("Login", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) From the Home view, it works, resulting in this url: http://localhost:12676/Account/Login But then, when another area is accessed, the ActionLink results in this url: http://localhost:12676/Admin/ManagerAccounts/Login/loginLink What do I need to change to cause the ActionLink to always result in ~/Account/Login ? 回答1: To force the ActionLink to be

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

对着背影说爱祢 提交于 2019-12-22 03:50:13
问题 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

@Html.ActionLink one works and one does not

纵然是瞬间 提交于 2019-12-13 00:08:32
问题 I have two @Html.ActionLink's one works and one does not and I cannot figure out why? They are both within the same controller: StoreController and both call ActionResults within different controllers, this is the one that works and calls the Index function within the Director Class: <ul> @foreach (var item in Model) { <li> <h2>@item.Title</h2> </li> <li class = "lihead"> Directed by @Html.ActionLink((string)item.Director.Name, "Index", "Director", new { searchString = item.Director.Name },

Adding images within Html.ActionLink

痞子三分冷 提交于 2019-12-12 08:22:05
问题 I was trying to create an option to switch between a list view and widget view in ASP.net MVC (with razor view engine). However, I am having some trouble trying to both add an image, as well as scale it to the 'correct height' (the same height as the next next to it). I was looking to create something like: Desired Result: --------------------------------------------------------------------------------- [≡­] List View | [+] Widget View ---------------------------------------------------------