url.action

URL.Action includes id when constructing URL

牧云@^-^@ 提交于 2019-11-27 14:41:53
问题 I'm using ASP.Net MVC. Here's my code snippets from a controller named Course: public ActionResult List(int id) { var viewmodel.ShowUrl = Url.Action("Show", "Course"); ... } public ActionResult Show(int id) { ... } viewmodel.ShowUrl picks up whatever the value is of the "id" parameter. So viewmodel.ShowUrl becomes "/Course/Show/151" (value of id is 151); I want to be able to set the id part on the client based on user interaction. I want the value of viewmodel.ShowUrl to be "/Course/Show".

How to pass Area in Url.Action?

孤街醉人 提交于 2019-11-27 11:26:39
问题 The problem in Html.ActionLink() is that you can't add additional html content inside the tag that it generates. For example, if you want to add an icon besides the text like: <a href="/Admin/Users"><i class="fa fa-users"></i> Go to Users</a> Using Html.ActionLink(), you can only generate: <a href="/Admin/Users">Go to Users</a> So, to resolve this, you can use Url.Action() to generate only the URL inside the tag like: // Here, Url.Action could not generate the URL "/admin/users". So this

Url.Action parameters?

梦想与她 提交于 2019-11-27 00:29:22
In listing controller I have, public ActionResult GetByList(string name, string contact) { var NameCollection = Service.GetByName(name); var ContactCollection = Service.GetByContact(contact); return View(new ListViewModel(NameCollection ,ContactCollection)); } In ASPX page I call, <a href="<%:Url.Action("GetByList","Listing" , new {name= "John"} , new {contact="calgary, vancouver"})%>"><span>People</span></a> I have a problem in the ASPX code... I can pull the records for the name john. but when I give the contact="calgary, vancouver", the webpage goes to error. How can I call two parameters

Pass a javascript variable as parameter to @url.Action()

£可爱£侵袭症+ 提交于 2019-11-26 23:12:06
is it possible to pass a javascript variable as a parameter to @url.Action(), because as far as i know there may be server and client side issue, my requirement is i have to download the file according to filter, and ajax call doesnot work with downloading the file. so i have harcode the @url.Action() that works but can not able to implement this, can anyone suggest me how to pass the parameter to @url.Action() or any other approach. here is my code <a href="@Url.Action("Export", new { SelectedAccountType="1", FromDate = "2014-02-02", ToDate = "2014-02-02", SelectedAccount = "", SelectedUser =

Pass a javascript variable as parameter to @url.Action()

人盡茶涼 提交于 2019-11-26 08:38:01
问题 is it possible to pass a javascript variable as a parameter to @url.Action(), because as far as i know there may be server and client side issue, my requirement is i have to download the file according to filter, and ajax call doesnot work with downloading the file. so i have harcode the @url.Action() that works but can not able to implement this, can anyone suggest me how to pass the parameter to @url.Action() or any other approach. here is my code <a href=\"@Url.Action(\"Export\", new {

Url.Action parameters?

夙愿已清 提交于 2019-11-26 08:05:27
问题 In listing controller I have, public ActionResult GetByList(string name, string contact) { var NameCollection = Service.GetByName(name); var ContactCollection = Service.GetByContact(contact); return View(new ListViewModel(NameCollection ,ContactCollection)); } In ASPX page I call, <a href=\"<%:Url.Action(\"GetByList\",\"Listing\" , new {name= \"John\"} , new {contact=\"calgary, vancouver\"})%>\"><span>People</span></a> I have a problem in the ASPX code... I can pull the records for the name