Questions tagged [routevalues]
50 questions
3
votes
2 answers
How to add a parameter to the current URL in a view?
I have a web application based an ASP.NET MVC4 in which I use a layout that contains three language flags (images). These flags are visible throughout the whole site. Now I want to use these images for language selection. In order to show any of the…

Rob
- 11,492
- 14
- 59
- 94
3
votes
2 answers
Pass dictionary from view to controller after form submit
Razor view:
@using (Html.BeginForm("Move", "Details", new { dict= dictionary}, FormMethod.Post)) {
//table with info and submit button
//dictionary => is a dictionary of type
}
Controller…

Sllix
- 606
- 9
- 28
3
votes
1 answer
Best way to add parameter to the current URL in ASP.NET MVC3
I ask a similar question here, I need to keep current URL and add new parameter to it, the only answer (yet) is :
RouteValueDictionary rt = new RouteValueDictionary();
foreach(string item in Request.QueryString.AllKeys)
rt.Add(item, …

Saeid
- 13,224
- 32
- 107
- 173
2
votes
2 answers
ASP.net MVC RouteLink and optional routeValues
I'm trying to figure out how to conditionally set a routeValue which is optional.
I have
<%= Html.RouteLink("<<<","Products",new { page=(Model.Products.PageIndex) }) %>
If a visitor clicks on a "category" I only show products of that category, but…

dtc
- 10,136
- 16
- 78
- 104
2
votes
1 answer
How can I generate url from non-controller static class in asp.net mvc 2 project?
I have created Html helper class in asp.net mvc2 project:
public static class CaptionExtensions
{
public static string Captions(this HtmlHelper helper, Captions captions)
{
var sb = new StringBuilder();
…

Cemsha
- 183
- 3
- 14
2
votes
2 answers
How to specify controller in ActionLink html helper in C#
I have a web application developed in ASP.NET MVC3 with C# and Razor.
I would like to call a specific Action Method of a specific Controller by using the ActionLink HTML helper. I know that the second parameter of ActionLink specifies the Action…

CiccioMiami
- 8,028
- 32
- 90
- 151
2
votes
2 answers
Optional route parameters and action selection
I use the default route definition:
{controller}/{action}/{id}
where id = UrlParameter.Optional. As much as I understand it this means when id is not being part of the URL this route value will not exists in the RouteValues dictionary.
So this also…

Robert Koritnik
- 103,639
- 52
- 277
- 404
2
votes
4 answers
How can I pass some objects in ViewBag to the Action? - Preserve search, sort and paging options
I have a view which I show result of a search and sort in a paged list. I add column headers as links to be enable the user to sort based on a column this way:
@Html.ActionLink("Reference No", "Index",
new…

KayGee
- 93
- 6
2
votes
1 answer
Retain jquery tab position after Post action in asp.net mvc
I have a page with jquery tabs in which the user can update their Profile, Password, General in each tab.
When a user update the details in "General" tab, the post action will be called and it should retain the "General" tab back.
It can be…

Prasad
- 58,881
- 64
- 151
- 199
2
votes
2 answers
Reading in RouteValues to Controller
so I have a Url Action
Create new teacher & assign to account.
That passes in two routeValues: createAndAssign, and teacherID.
Now when I go…

Wesley
- 309
- 7
- 21
1
vote
2 answers
Dynamic named parameter in route values collection using Razor view
I use a helper method to create sections in my view:
@helper CreateFacetSection(WebViewPage page, string sectionName,
List model)
{
var showMore =…

Leniel Maccaferri
- 100,159
- 46
- 371
- 480
1
vote
1 answer
MVC3 .NET Ajax.ActionLink using POST option and URL generated shows id
I have Ajax.ActionLink that POSTS to a method on a controller and passes an Id.
It definitely posts as I have decorated the method with: [HttpPost].
The url is displaying the Id value.
Is this correct, as I would have thought POSTing would hide the…

user1079925
- 541
- 2
- 8
- 20
1
vote
2 answers
ASP.NET MVC route values and view model
Here is a strange issue I'm experiencing.
The model:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
The view:
@model Person
@Html.TextBoxFor(m => m.FirstName)
…

Q. Young
- 45
- 5
1
vote
2 answers
Send single value through RouteValueDictionary
One of the properties of my ViewModel is an array which, unfortunately, is null every time I post back to the controller. I figured a simple hack where I place the values into a coma-delimited string.
This works great for our paging plugin, which…

NealR
- 10,189
- 61
- 159
- 299
0
votes
1 answer
ASP.NET MVC - Is it possible to generate cross-application action links?
is it possible to generate cross-application action links using the HTML helper class?
I have the following (both are separate VS2008 projects):
http://mainwebsite/
http://mainwebsite/application
I would like to generate a link IN the…

Ropstah
- 17,538
- 24
- 120
- 194