actionlink

Actionlink with no routeValues being loaded with routeValue breaking dynamic pages

南笙酒味 提交于 2019-12-24 08:34:50
问题 When you have an actionlink that is written with no routeValues and you load that page with a routeValue specified MVC writes out the actionlink incorrectly. I have had exactly the same bug with MVC attribute routing as well where you specify a url something like this: [Route("reviews/{reviewId}")] I have escpecially had problems with this where it breaks dynamic content pages that are loaded by a routeValue and when you have multiple actionlinks that point to the dynamic action result on the

How to create an ActionLink with Properties for the View Model

☆樱花仙子☆ 提交于 2019-12-23 10:09:31
问题 I have a ViewModel with a Filter property that has many properties that I use to filter my data Example: class MyViewModel : IHasFilter { public MyData[] Data { get; set; } public FilterViewModel Filter { get; set; } } class FilterViewModel { public String MessageFilter { get; set; } //etc. } This works fine when using my View. I can set the properties of Model.Filter and they are passed to the Controller. What I am trying to do now, is create an ActionLink that has a query string that works

ASP MVC 3 RequireHttps attribute change all links to https

不羁的心 提交于 2019-12-23 09:03:20
问题 I have an ASP MVC 3 website that has a Feedback form and should require SSL. Now, I have an action called Feedback inside a controller called 'ContactUs' that is responsible for viewing and processing the feedback. When I used the [RequireHttps] attribute on that action, it works nice and it changes the URL to "https". However, I noticed that all the links inside my page are now pointing to "https"! As if this attribute had forced the routing engine to apply the same to all links!!! Of course

How do I stop an Actionlink redirect and instead popup and redirect using javascript?

江枫思渺然 提交于 2019-12-23 03:21:47
问题 This is script what I have currently - <script type="text/javascript"> $(document).ready(function () { $('.RemoveSystem').click(function () { var href = $(this).attr('href'); var answer = confirm("Are you sure you want to delete this system?"); alert(answer); if (answer) window.location = href; }); }); </script> Here is the link which is there for each record and we can delete each system when we click on its delete button - <%= Html.ActionLink("Delete", "RemoveSystem", new { SysNum = item.Id

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

Html.ActionLink with id value from a dropdownlist

馋奶兔 提交于 2019-12-22 05:54:29
问题 I've got a dropdownlist: <%= Html.DropDownList("ddlNames", new SelectList(Model.NameList, "ID", "Name"))%> I've got an ActionLink: <%: Html.ActionLink("edit", "Edit", "Members", new { area = "MembersArea", id = XXX }, null)%> I want the value of the dropdownlist in the XXX. So I want to use values from controls on a view in the ActionLink. Is that possible in a simple manner? thanks, Filip 回答1: You can't do this because the html helpers execute at the server side while the dropdown value can

Ajax.ActionLink vs Html.ActionLink + Jquery.Ajax call

孤街醉人 提交于 2019-12-21 12:11:12
问题 I can call an asp.net mvc controller via Ajax.ActionLink("Get customers","GetCustomers","Customer"); I can do the same with the Html.ActionLink and a jquery ajax call. Where is the difference? 回答1: Where is the difference? In the amount of code you have to write (less with Ajax.ActionLink) and the level of control you need (more with Html.ActionLink and a jquery ajax call). So it's amount of code vs level of control and functionality needed => up to you to decide which one you need. Both

ASP.NET MVC add css class to actionlink [duplicate]

人走茶凉 提交于 2019-12-18 12:47:10
问题 This question already has answers here : How do I add a class to an @Html.ActionLink? (4 answers) Closed 3 years ago . How do I add a css class to this actionlink? I have read you do it something like new { class = button } but I'm not sure where to put it within my actionlink: <%= Html.ActionLink("View Performances", "Details", "Productions", new { name = item.show , year = item.year }, null) %> 回答1: you can try <%= Html.ActionLink("View Performances", "Details", "Productions", new { name =

Create a custom ActionLink

你。 提交于 2019-12-18 07:18:17
问题 I want to create a custom actionlink but I don't know how to do this while fulfilling my needs. I worked with custom htmlhelpers before but this is a bit more tricky for me. The actionlink that I want to call needs to be like this: @Html.CustomActionLink("LinkText", "Area","Controller","TabMenu","Action",routeValues, htmlAttributes) so an example would be: @Html.CustomActionLink("Click here","Travel","Trip","Index","Index", new { par1 = "test", par2 = test2, new { @class = "font-color-blue" }

Convert submit button to ActionLink

限于喜欢 提交于 2019-12-13 07:18:00
问题 Is there a way to convert the submit button with an ActionLink ? I got this ActionLink which redirects the user to the index page: @Html.ActionLink("Cancel", "Index", null, new { @class = "k-button" }) And a save button which submits to save whatever is created or altered: <input type="submit" value="Save" /> It would be nice to have the submit button the same code as the ActionLink . 回答1: You could use an <a> tag directly, try something like this: <a onclick="$('#YourForm').submit();" class=