actionlink

Ajax.ActionLink is not POSTing

做~自己de王妃 提交于 2019-12-08 21:03:11
问题 I am trying to navigate to an MVC action by POSTing rather than GETting. (The action is a DELETE, and I don't want it reachable by an external link.) I am using a link in a grid generated by Ajax.ActionLink("Remove", "Delete", new { saID = Model.Said, id = e.id }, new AjaxOptions { HttpMethod = "POST", Confirm = "Are you sure you want to delete this item?" }) Which generates the following HTML: <a href="/Equipment/Delete/102424/229933" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys

How is OnSuccess measured for a ASP.NET MVC ActionLink?

心不动则不痛 提交于 2019-12-08 18:33:27
问题 I don't exactly understand how ASP.NETs ActionLinks work. I see that they have a event handler for OnSuccess and OnFailure, but I can't find anything that describes how success and failure is determined. I'm building an ASP.NET MVC application and within it I have a Ajax.ActionLink that allows me to "vote" on items using AJAX...similiar to Digg. The Actionlink kicks off my Controller and method...everything is working fine here. In my controller I have logic that checks to see if this user

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

半城伤御伤魂 提交于 2019-12-08 09:11:28
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}, new { @class = "RemoveSystem" })%> Now here is the problem the actionlink redirects no matter what

Ajax.ActionLink, get data or error message from controller?

蹲街弑〆低调 提交于 2019-12-08 04:54:30
问题 Here is a spot that I want to update: <div style="text-align: center;" id="vote_count">@Html.DisplayFor(q => q.VoteCount)</div> Here is my actionLink: @Ajax.ActionLink("Upvote", "Upvote", "Author", new { QuestionID = Model.QuestionID, @class = "upvote" }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "vote_count", OnBegin = "onBegin", OnComplete = "onComplete", OnSuccess = "onSuccess", OnFailure = "onFailure" }) And here is one of my controllers: public int Upvote

Edit Html.ActionLink output string

一笑奈何 提交于 2019-12-08 04:28:12
问题 I'm trying to output the following HTML using Html.ActionLink: <a href="/About" class="read-more">Read More<span class="arrow">→</span></a> I'm getting it done by doing an ActionLink, which outputs an <a> tag and then manipulating the string. <%= Html.ActionLink("[[replace]]", "Index", "About", null, new { @class = "read-more" }).ToHtmlString().Replace("[[replace]]", "Read More" + "<span class='arrow'>→</span>")%></p> It'd be good if I could put HTML directly into the ActionLink but there

ASP.Net MVC AJAX link not working

旧巷老猫 提交于 2019-12-08 01:45:17
问题 I have this link, in an effort to implement AJAX log on, on my page: <%= Ajax.ActionLink("Log On", "LogOn", "Account", new AjaxOptions { UpdateTargetId = "lll", Confirm = "blah"}) %> There's a div with id lll nearby. When I click the link, I get the blah confirmation (just added for debugging purposes, the behavior without it it's the same) but then nothing happens. No request ever reaches the server (because I have a breakpoint on the LogOn action method). That is in Chrome and IE8. In FF3

ActionLink with multiple classes in ASP.NET MVC3

老子叫甜甜 提交于 2019-12-07 08:34:13
问题 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" }) 回答1: 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

Problems doing a proper HTTP Delete with Ajax.ActionLink

喜你入骨 提交于 2019-12-07 03:23:53
问题 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

Edit Html.ActionLink output string

为君一笑 提交于 2019-12-06 16:42:16
I'm trying to output the following HTML using Html.ActionLink: <a href="/About" class="read-more">Read More<span class="arrow">→</span></a> I'm getting it done by doing an ActionLink, which outputs an <a> tag and then manipulating the string. <%= Html.ActionLink("[[replace]]", "Index", "About", null, new { @class = "read-more" }).ToHtmlString().Replace("[[replace]]", "Read More" + "<span class='arrow'>→</span>")%></p> It'd be good if I could put HTML directly into the ActionLink but there doesn't seem to be a way based on my internet searches. Sure, it works but it seems like a hack. Is there

ASP.Net MVC AJAX link not working

寵の児 提交于 2019-12-06 07:20:59
I have this link, in an effort to implement AJAX log on, on my page: <%= Ajax.ActionLink("Log On", "LogOn", "Account", new AjaxOptions { UpdateTargetId = "lll", Confirm = "blah"}) %> There's a div with id lll nearby. When I click the link, I get the blah confirmation (just added for debugging purposes, the behavior without it it's the same) but then nothing happens. No request ever reaches the server (because I have a breakpoint on the LogOn action method). That is in Chrome and IE8. In FF3 it opens the logon view but as a page, it doesn't download it through AJAX. Any ideas what might be