actionlink

asp.net mvc: How to image map?

北慕城南 提交于 2019-12-06 06:29:52
How in ASP.NET MVC would I construct an image map? For ref: <map id='headerMap'> <area shape='rect' href="Default.aspx" coords='300,18,673,109' /> </map> One answer of an answer of an unrelated question by markus is something similar: <a href="<%= Url.RouteUrl("MyRoute", new { param1 = "bla", param2 = 5 }) %>"> put in <span>whatever</span> you want, also <img src="a.gif" alt="images" />. </a> Sorry if this is redundant. My research indicated that this may be a version 2 mvc answer. Looking for something similar to Html.ActionLink if it exists. Obviously, I could reference the route by name and

ActionLink with multiple classes in ASP.NET MVC3

╄→гoц情女王★ 提交于 2019-12-05 12:57:29
I'm curious, is it possible to use multiple CSS classes on an ActionLink in MVC3 Razor syntax? The line below appears to load only the first class(btn) and skipps btn_c. @Html.ActionLink("Administration", "Index", "Admin", null, new { @class = "btn btn_c" }) I've just used your existing ActionLink with the following css: .btn { color: yellow; } .btn_c { background-color: red; } And it successfully produced the following output: 来源: https://stackoverflow.com/questions/8465133/actionlink-with-multiple-classes-in-asp-net-mvc3

Html.ActionLink with id value from a dropdownlist

假装没事ソ 提交于 2019-12-05 10:30:48
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 You can't do this because the html helpers execute at the server side while the dropdown value can change at the client side. The only way to achieve it is to use javascript. You could register for the

Problems doing a proper HTTP Delete with Ajax.ActionLink

淺唱寂寞╮ 提交于 2019-12-05 08:15:28
What i'm trying to do: Try to delete a record using a "proper" HTTP Delete. Controller Code: [HttpDelete] public void DeleteRun(int RunId) { repository.RemoveEntry(RunId); } Razor View: @Ajax.ActionLink("Delete","DeleteRun",new {RunId = run.RunId}, new AjaxOptions() { Confirm = "Are you sure you want to delete this entry?", HttpMethod = "DELETE", OnComplete = string.Format("DeleteRunInTable({0})",run.RunId) }) Javascript (in separate included file): function DeleteRunInTable(RunId) { $("tr[data-runid=" + RunId).remove(); } Link the actionlink method is creating: <a data-ajax="true" data-ajax

Issue with Ajax.ActionLink incorrectly rendering links when using htmlAttributes

◇◆丶佛笑我妖孽 提交于 2019-12-05 07:41:30
问题 Does anyone know of any issues with rendering incorrect querystrings when using htmlAttributes in an Ajax.ActionLink? It seems that if I put even an empty array in for the htmlAttributes, the link gets rendered incorrectly. Here's my code. When I do this (note the new { }): <%= Ajax.ActionLink("Delete", "Delete", "Milestone", new RouteValueDictionary { { "id", Model.Id } }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", OnSuccess = "modalDelete" }, new { })%>

ASP.NET MVC: generating action link with custom html in it

别等时光非礼了梦想. 提交于 2019-12-05 04:10:27
How can I generate action link with custom html inside. Like following: <a href="http://blah-blah/....."> <span class="icon"/> New customer </a> You can use the UrlHelper class : <a href="<% =Url.Action("Create","Customers") %>"> <span class="icon"/> New customer </a> The MSDN link is here : http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx 来源: https://stackoverflow.com/questions/3879547/asp-net-mvc-generating-action-link-with-custom-html-in-it

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

How do I create the correct route values for this ActionLink?

落花浮王杯 提交于 2019-12-04 15:58:12
问题 The Model of SearchResults.aspx is an instance of PersonSearch ; when the request for a new page arrive (a GET request), the action method should take it and compute the new results. [AcceptVerbs(HttpVerbs.Get)] public ActionResult SearchResults(PersonSearch search, int? page) { ViewData["Results"] = new PaginatedList<Person>(_searchService.FindPersons(search), page ?? 0, 1); return View("SearchResults", search); } Then I have to generate the previous/next links: <%= Html.ActionLink("Next

MVC Ajax.ActionLink doesn't find POST method

心已入冬 提交于 2019-12-04 09:29:52
问题 I have a POST method declared in my controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateComments(int id, string comments) { // ... } and an ActionLink in my view: <%= Ajax.ActionLink("update", "UpdateComments", new { id = Model.Id, comments = "test" }, new AjaxOptions { HttpMethod="POST", OnFailure="alert('fail');", OnSuccess = "alert('success');" })%> I get a "not found" error when it tries to route this request. If I remove the POST restriction from the UpdateComments method

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

时光怂恿深爱的人放手 提交于 2019-12-04 04:37:34
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? 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 approaches are perfectly fine. The Ajax.ActionLink uses the jquery.unobtrisuve-ajax script to AJAXify the anchor