actionlink

What's the difference between RouteLink and ActionLink in ASP.NET MVC?

笑着哭i 提交于 2019-11-26 12:38:06
问题 I think that the title pretty much sums it up: What\'s the difference between RouteLink() and ActionLink() in ASP.NET MVC? i.e. when do you use Html.RouteLink() and when do you use Html.ActionLink() in your View? 回答1: Action and Routes don't have to have a 1:1 relationship. ActionLink will generate the URL to get to an action using the first matching route by action name. RouteLink will generate a URL to a specific route determined either by name or route values. 回答2: Actually, the output

asp.net mvc Html.ActionLink() keeping route value I don't want

若如初见. 提交于 2019-11-26 11:00:45
问题 I have the following ActionLink in my view <%= Html.ActionLink(\"LinkText\", \"Action\", \"Controller\"); %> and it creates the following URL http://mywebsite.com/Controller/Action Say I add an ID at the end like so: http://mywebsite.com/Controller/Action/53 and navigate to the page. On this page I have the markup I specified above. Now when I look at the URL it creates it looks like this: http://mywebsite.com/Controller/Action/53 (notice the addition of the ID) But I want it to remove the ID

ASP.NET MVC ActionLink and post method

丶灬走出姿态 提交于 2019-11-26 10:27:37
Can anyone tell me how can I submit values to Controller using ActionLink and POST method? I don't want to use buttons. I guess it has something with jquery. You can't use an ActionLink because that just renders an anchor <a> tag. You can use a jQuery AJAX post . Or just call the form's submit method with or without jQuery (which would be non-AJAX), perhaps in the onclick event of whatever control takes your fancy. If you're using ASP MVC3 you could use an Ajax.ActionLink(), that allows you to specify a HTTP Method which you could set to "POST". You can use jQuery to do a POST for all your

Putting HTML inside Html.ActionLink(), plus No Link Text?

笑着哭i 提交于 2019-11-26 07:55:25
问题 I have two questions: I\'m wondering how I can display no link text when using Html.ActionLink() in an MVC view (actually, this is Site.Master ). There is not an overloaded version that does not allow link text, and when I try passing in just a blank string , the compiler tells me it needs a non-empty string. How can I fix this? I need to put <span> tags within the anchor tag, but it\'s not working with Html.ActionLink(); . I\'d like to see the following output: Span text How can I put tags

Html.ActionLink as a button or an image, not a link

佐手、 提交于 2019-11-26 03:36:36
问题 In the latest (RC1) release of ASP.NET MVC, how do I get Html.ActionLink to render as a button or an image instead of a link? 回答1: Late response but you could just keep it simple and apply a CSS class to the htmlAttributes object. <%= Html.ActionLink("Button Name", "Index", null, new { @class="classname" }) %> and then create a class in your stylesheet a.classname { background: url(../Images/image.gif) no-repeat top left; display: block; width: 150px; height: 150px; text-indent: -9999px; /*

ASP.NET MVC ActionLink and post method

百般思念 提交于 2019-11-26 02:09:12
问题 Can anyone tell me how can I submit values to Controller using ActionLink and POST method? I don\'t want to use buttons. I guess it has something with jquery. 回答1: You can't use an ActionLink because that just renders an anchor <a> tag. You can use a jQuery AJAX post. Or just call the form's submit method with or without jQuery (which would be non-AJAX), perhaps in the onclick event of whatever control takes your fancy. 回答2: If you're using ASP MVC3 you could use an Ajax.ActionLink(), that

HTML.ActionLink method

只愿长相守 提交于 2019-11-25 23:29:13
问题 Let\'s say I have a class public class ItemController:Controller { public ActionResult Login(int id) { return View(\"Hi\", id); } } On a page that is not located at the Item folder, where ItemController resides, I want to create a link to the Login method. So which Html.ActionLink method I should use and what parameters should I pass? Specifically, I am looking for the replacement of the method Html.ActionLink(article.Title, new { controller = \"Articles\", action = \"Details\", id = article