url.action

ASP.NET HTML.BeginForm/Url.Action Url points to itself

眉间皱痕 提交于 2019-12-12 04:59:03
问题 I facing an issue with the ASP.NET BeginForm helper. I try to create a form that should point to /Project/Delete and I tried the following statemant to reach this target: @using (Html.BeginForm("Delete", "Project")) { } <form action="@Url.Action("Delete", "Project")"></form> But unfortunately both rendered actions points to /Projects/Delete/LocalSqlServer , which is the url of site called in the browser <form action="/Project/Delete/LocalSqlServer" method="post"></form> I really dont know why

how may i add integer list to route

限于喜欢 提交于 2019-12-04 22:00:19
问题 I'm trying to add int[] array to my Url.Action something like this: var routeData = new RouteValueDictionary(); for (int i = 0; i < Model.GroupsId.Length; i++) { routeData.Add("GroupsId[" + i + "]", Model.GroupsId[i]); } in my view: Url.Action("Index", routeData) but in html I'm getting: GroupsId%5B0%5D=1213&GroupsId%5B0%5D=1214 and not: GroupsId=1213&GroupsId=1214 I need it because I have a checkbox list, and when I do post I'm binding groupIds to int[] and then pass to view where I have

How do I stop URL.Action from including parameters?

浪尽此生 提交于 2019-12-01 16:59:14
In my main navigation I have a link to: Url.Action("Items", "FAQ"); The link works fine and I get to ~/Item/FAQ However, I have links which contain parameters, so: ~/Items/FAQ/Question-1 This all works fine, however, when I'm viewing Question-1 (which is a View, the link in the main navigation changes to: ~/Items/FAQ/Question-1 How do I keep the Url in the navigation to stay at ~/Items/FAQ Thanks! Url.Action("Items", "FAQ", new { WhateverYourRouteParameterIsCalled = "" }) I tried the answer but couldn't get it to work. In the end, I used a (comparatively) low tech solution: <a href="@Url

How do I stop URL.Action from including parameters?

六眼飞鱼酱① 提交于 2019-12-01 15:57:36
问题 In my main navigation I have a link to: Url.Action("Items", "FAQ"); The link works fine and I get to ~/Item/FAQ However, I have links which contain parameters, so: ~/Items/FAQ/Question-1 This all works fine, however, when I'm viewing Question-1 (which is a View, the link in the main navigation changes to: ~/Items/FAQ/Question-1 How do I keep the Url in the navigation to stay at ~/Items/FAQ Thanks! 回答1: Url.Action("Items", "FAQ", new { WhateverYourRouteParameterIsCalled = "" }) 回答2: I tried

How to pass dynamic value in @Url.Action?

馋奶兔 提交于 2019-11-29 06:17:47
问题 I have written following jquery in my partial view: $.ajax({ type: "POST", url: '@Url.Action("PostActionName", "ControllerName")', data: { Id: "01" }, success: function(data) { if (data.success="true") { window.location = '@Url.Action("GetActionName", "ControllerName")' } } }); The Action name and Controller name are not fixed, they are bound to change depending upon the view wherein this partial view is placed. I have functions to fetch invoking action and controller names, but not sure how

MVC3 unterminated string constant syntax error

风格不统一 提交于 2019-11-29 04:35:58
I have the following code which gives me a syntax error - unterminated string constant.I've matched up the quotes can't seem to spot an issue. Any ideas? It works fine, the syntax error is just annoying. <input type="button" class="my-button" value="" name="back" onclick="location.href='@Url.Action(Model.Back.Step.ToString(), "MyController")'" /> You can rewrite it like this: <input type="button" class="my-button" value="" name="back" onclick="@("location.href='" + Url.Action(Model.Back.Step.ToString(), "MyController") + "'")" /> Ian Use an actionlink instead. This one creates a nice bootstrap

Url.Action puts an & in my url, how can I solve this?

主宰稳场 提交于 2019-11-29 00:48:06
I want to send the variables itemId and entityModel to the ActionResult CreateNote: public ActionResult CreateNote( [ModelBinder(typeof(Models.JsonModelBinder))] NoteModel Model, string cmd, long? itemId, string modelEntity) with this javascript: Model.meta.PostAction = Url.Action("CreateNote", new { cmd = "Save", itemId = itemId, modelEntity = modelEntity}); However, the url being send is localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44 I want to send localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44 How can I

URL.Action includes id when constructing URL

流过昼夜 提交于 2019-11-28 23:04:25
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". This seems like a bug to me. I'm not telling Url.Action to include an id value. It's doing it on its own.

How to pass Area in Url.Action?

别等时光非礼了梦想. 提交于 2019-11-28 18:33:05
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 doesn't work. <a href="@Url.Action("", "Users", "Admin")"><i class="fa fa-usesr"></i> Go to Users</a> //

MVC3 unterminated string constant syntax error

ⅰ亾dé卋堺 提交于 2019-11-27 18:31:45
问题 I have the following code which gives me a syntax error - unterminated string constant.I've matched up the quotes can't seem to spot an issue. Any ideas? It works fine, the syntax error is just annoying. <input type="button" class="my-button" value="" name="back" onclick="location.href='@Url.Action(Model.Back.Step.ToString(), "MyController")'" /> 回答1: You can rewrite it like this: <input type="button" class="my-button" value="" name="back" onclick="@("location.href='" + Url.Action(Model.Back