actionlink

Issue with Ajax.ActionLink incorrectly rendering links when using htmlAttributes

这一生的挚爱 提交于 2019-12-03 23:10:32
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 { })%> The link renders like this: <a href="/Client/1/Admin/Milestone/Delete?Count=1&Keys=System.Collections

Passing parameters to MVC Ajax.ActionLink

狂风中的少年 提交于 2019-12-03 15:57:29
How can I send the value of the TextBox as a parameter of the ActionLink? I need to use the Html.TextBoxFor <%= Html.TextBoxFor(m => m.SomeField)%> <%= Ajax.ActionLink("Link Text", "MyAction", "MyController", new { foo = "I need here the content of the textBox, I mean the 'SomeField' value"}, new AjaxOptions{ UpdateTargetId = "updateTargetId"} )%> The Contoller/Actions looks like this: public class MyController{ public ActionResult MyAction(string foo) { /* return your content */ } } Using MVC 2.0 How can I send the value of the TextBox as a parameter of the ActionLink? The semantically

Html.ActionLink with a specified HTML id?

允我心安 提交于 2019-12-03 10:29:56
问题 I'd like to give the like generated with an Html.ActionLink an HTML id so I can change the CSS depending on where I am. I have a MasterPage with a set of links and I'd like to distinguish the active "Tab" with Jquery changing the css of that active #id Right now I'm using: <%: Html.ActionLink("Some View", "Index", "controller")%> It generates: <a href="/controller">Some View</a> I'd like to generate: <a id="something" href="/controller">Some View</a> Is that possible? I've tried: <%: Html

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

末鹿安然 提交于 2019-12-03 10:00:24
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 Page >", "SearchResults", routeValues) %> If I use routeValues = ViewData.Model I can see the object

ASP.NET MVC 3 (Razor) Ajax.ActionLink - What am i doing wrong?

僤鯓⒐⒋嵵緔 提交于 2019-12-03 08:08:40
问题 Trying to have a AJAX action link which when clicked, should do a HttpGet to an action method which returns a PartialViewResult and shoves the HTML into a div. Here's my View: <div id="admin-options" class="admin"></div> @Ajax.ActionLink("Show Admin Options", "ShowOptions", "Post", new { area = "Admin" }, new AjaxOptions { UpdateTargetId = "admin-options", HttpMethod = "GET" }) Here's the action method: public class PostController : Controller { [HttpGet] [Authorize(Roles="Admin")] public

Html.ActionLink with a specified HTML id?

吃可爱长大的小学妹 提交于 2019-12-03 00:59:10
I'd like to give the like generated with an Html.ActionLink an HTML id so I can change the CSS depending on where I am. I have a MasterPage with a set of links and I'd like to distinguish the active "Tab" with Jquery changing the css of that active #id Right now I'm using: <%: Html.ActionLink("Some View", "Index", "controller")%> It generates: <a href="/controller">Some View</a> I'd like to generate: <a id="something" href="/controller">Some View</a> Is that possible? I've tried: <%: Html.ActionLink("Some View", "Index", "controller", new {id="blahbla")%> But that generates: <a href="

ASP.NET MVC 3 (Razor) Ajax.ActionLink - What am i doing wrong?

删除回忆录丶 提交于 2019-12-02 21:40:43
Trying to have a AJAX action link which when clicked, should do a HttpGet to an action method which returns a PartialViewResult and shoves the HTML into a div. Here's my View: <div id="admin-options" class="admin"></div> @Ajax.ActionLink("Show Admin Options", "ShowOptions", "Post", new { area = "Admin" }, new AjaxOptions { UpdateTargetId = "admin-options", HttpMethod = "GET" }) Here's the action method: public class PostController : Controller { [HttpGet] [Authorize(Roles="Admin")] public PartialViewResult ShowOptions() { return PartialView(); } } Here's the HTML it generates: <a data-ajax=

MVC Html.ActionLink removes empty querystring parameter from URL

江枫思渺然 提交于 2019-12-01 18:53:31
问题 I'm using the Html.ActionLink(string linkText, string actionName, object routeValues) overload to send some params to an Action Method.. Sometimes I need to pass an empty parameter value like: ?item1=&item2=value I'm specifying the param in the anonymous type I create and pass as routeValues , but both null and string.Empty result in a URL that omits the empty item1 param. new { item1 = null, item2 = "value" } new { item1 = string.Empty, item2 = "value" } new { item1 = "", item2 = "value" } /

MVC Html.ActionLink removes empty querystring parameter from URL

北慕城南 提交于 2019-12-01 18:24:23
I'm using the Html.ActionLink(string linkText, string actionName, object routeValues) overload to send some params to an Action Method.. Sometimes I need to pass an empty parameter value like: ?item1=&item2=value I'm specifying the param in the anonymous type I create and pass as routeValues , but both null and string.Empty result in a URL that omits the empty item1 param. new { item1 = null, item2 = "value" } new { item1 = string.Empty, item2 = "value" } new { item1 = "", item2 = "value" } // all result in: ?item2=value I can create the URL manually but I want to use the helper method.

How can I pass a Textboxes value to my Ajax.ActionLink?

二次信任 提交于 2019-12-01 17:08:24
问题 In my ASP.NET MVC application I want a user to add a value into a textbox and then press my Ajax.ActionLink. I want to do something like this: Ajax.ActionLink("Go", "Action", "Controller", new { value = textbox1.value }) Or how else can I get this textbox value back to my action? Jquery? 回答1: You may run action using AJAX $.get method: <script type="text/javascript"> $(document).ready(function() { $("#t").change(function() { RunAction(); }); RunAction(); }); function RunAction() { var action