.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

MVC Route with multiple id: controller/action/id1/id2

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
Hi, I'd like to provide a route which handles a URL like this: 'http://my.com/Shop/Departments/Garden/Rakes' Is there a way to create a route which picks up & passes in the parameters 'Garden' and 'Rakes'? Or do I need to take 'Garden/Rakes' from one id parameter as a string and handle it myself? Thanks, +M    

View Complete Post

More Related Resource Links

How can i route to different actions having same signature if i don't want to pass action name in U

I am having one controller Test having following actions (1)public ActionResult ABC (string parameter1, string parameter2)       (2)public ActionResult XYZ (string parameter1, string parameter2,string parameter3, string parameter4)       i have added following html.routelinks  <%= Html.RouteLink("ABC","ABC", new { parameter1 = 100, parameter2 = 200 } )%><br /> <%= Html.RouteLink("XYZ", "XYZ", new { parameter1 = 1000 , parameter2 = 2000 }) %> last two parameters in XYZ action are optionals so i have not passed them in Html.routelink  routes.MapRoute("ABC", "Test/{parameter1}/{parameter2}", new { controller = "Test", action = "ABC", parameter1= 0,parameter2=0 }); routes.MapRoute("XYZ", "Test/{parameter1}/{parameter2}/{parameter3}/{parameter4}", new { controller = "Test", action = "XYZ", parameter1=0,parameter2=0 ,parameter3=UrlParameter.Optional,parameter4=UrlParameter.Optional}); In above senario in both cases same route "ABC" is called eventhough i have clicked on second Html.routelink.can anyone solve this issue ? how can i route according to route name instead of number of parameters?

How do I implement the "Multiple Select" Action!

Hi everybody! Its me again! I was wondering, if there a possibility to implement the "Multiple Select" Action within a Document Library  into a SharePoint2007 customized list definition do get it ready for SharePoint 2010. Is it a special <tag> in on of the *.xml files (Schema.xml, Elements.xml) or just a configuration within SharePoint? Looking forward for some answers Thanks

Multiple repositories in controller?

HiI'm completely new to the MVC framework (having done everything in WebForms up until now). I've been playing around with it for the past couple of days and have a question about what to do if you have a view that displays two completely separate pieces of data. For example, if you wanted to display a list of products and somewhere else on the page you might want to display something about the user-related data (or whatever).The tutorials I've been practicing involve having a controller which creates an instance of a repository in the constructor. My initial instinct was to just create an instance of each repository that you need, but some people don't seem to look too favourably upon that. So what's the "proper" way of doing this?Thanks

How do I - pass multiple params from multi-select drop down on one report to another via action


Report 1 - 3 params:  @Status =Y,N  @FromDate, @ToDate.  Report one shows 2 cols (Status, Total). 

 @Status gets values from shared dataset - getStatus

Status      Totals
[Status]    [Total]

I created an action [Total] when clicked runs another report that accepts the same 3 params (Status, FromDate, ToDate) and works fine if i only select one of the status' from the status param drop down.

I am trying to create an action on [sum(Total)] that will run the same 2nd report with both status' selected.  Show it should show me details of all Y and N

The second report will work if i set the 2nd report @Status param to no default value.  But i want a user to be able to run the 2nd report by itself if needed so i set the @Status param to Get Values from a Query, which get the same dataset as report 1 which is getStatus.  It will not populate the 2nd report Status field when I do this.  I am forced to set it to no default values.  Is there a way to pass both the Y and N from report 1 to report 2 and still keep the drop down multi-select box on report 2 for Status?


Custom Form Field in Collect Data Action doesnot capture multiple users.


I have a situation where the department head dynamically assigns the reviewers depending on the document that is uploaded. To capture the reviewers I added a Collect Data Action and a "Reviewers" form field, with type "Person/Group" and checked the following properties

1. Allow selection od People and Groups, 2. Choose from all users and more importantly 3. Allow multiple users

Although I am able to enter multiple users in the form, I am able to retrieve only the first user I entered and the rest just.. disappear!

how to use jQuery to get MVC controller action?



I have this action on below

public ActionResult Edit(int id)

            var mtn0120 = __context.GetMtn0120(id);
            TempData["EditDateTime"] = mtn0120.EditDatetime;
            return View(mtn0120);

So how do I:

-use jquery $.get to access this action then redirect to the view?

-can I do it without using json?

-can I do it without modify the codes above?


Deleting a Controller Action and its View in one step


Since a Controller Action and its View are associated with each other I would think that there would be a way to delete both in one step.

Is that possible? 

Cascading action for multiple partial view in one view



I would like to create one view for my CRUD actions.  The view contains 3 basic DIV updatetargets ("search form", "search result listing" and "action" (would be create,detail,edit,delete).  Basic flow would be: "Search" updates the "Search Result Listing", click on CRUD actions in listing would show partial view in "action". 

Problem how do I call to refresh the "Listing" after I do any add/update/delete without having user click search again?


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Student Example</h2>
        <% using (Ajax.BeginForm("Search", "Student",
               new AjaxOptions { UpdateTargetId = "divSearchResult" }))
        { %>
        <%= Html.ValidationSummary(true) %>
            <legend>Student Search Criteria&

same processing for each action of a controller


I would like all actions of a controller to read some master page level values from the querystring and write those values to ViewState. How do I do this in ASP.NET MVC?



Calling action on Controller via AJAX


Hi All

I'm working on a forum application using MVC 2.0. I've built a basic page listing all the forum posts, held in a database and I've added a simple section on the bottom for a user to add a new post:

<% using (Ajax.BeginForm("AddChat", "Chat", new { text = Model.AddChat.Text}, new AjaxOptions { OnSuccess = "handleSuccess" }))


                <%: Html.ValidationSummary(true)%>





                        <div class="editor-label">

                            <%: Html.LabelFor(model => model.AddChat.Text)%>



Pass multiple values to an array parameter of an action


Hello guys,

ca anyone tell me how to get an url Like http://localhost/xxx/ControlerName/ActionName/2,3,4

to map to an Action having an int[] parameter?

For example to a Action with Signature:

1    public ActionResult Index(int[] ids)
2    {
4    }



1    public ActionResult Index(List<int> id)
2    {
4    }

I couldn't find any logic for doing this. So I've implemented an ActionFilterAttribute, but I would prefer to use an built in logic.
But if there's no built in logic, feel free to use my logic:



1    [ArrayOrListParameterAttribute("ids", ",")]
2    public ActionResult Index(List<int> ids)
3    {
5    }
7    [ArrayOrListParameterAttribute("ids", ","

Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend