Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:30:44+00:00 2026-06-14T19:30:44+00:00

I have a need to use ActionLink to link to ann edit screen for

  • 0

I have a need to use ActionLink to link to ann edit screen for my ViewModel A.

A has a composite key, so to link to it, the route values will have to have 3 pramaters, like this:

<%: Html.ActionLink("EDIT", "Action", "Controller", 
    new { area = "Admin", Id1= 1, Id2= 2, Id3= 3 })%>

As you can see, the route values contain the ids that the controller Action will accept.

I want to be able to generate the route values from a helper function, like this:

public static Object GetRouteValuesForA(A objectA)
    {
        return new
        {
            long Id1= objectA.Id1,
            long Id2= objectA.Id2,
            long Id3= objectA.Id3
        };
    }

And then use it in the ActionLink helper, but I don’t know how to pass that result to the ActionHelper

objectA = new A(){Id1= objectA.Id1,Id2= objectA.Id2,Id3= objectA.Id3};
....
<%: Html.ActionLink("EDIT", "Action", "Controller", 
    new { area = "Admin", GetRouteValuesForA(objectA) })%>

But that would need the controller action to accept that anonymous type instead of a list of 3 properties

I saw the below link that merges anonymous type, but is there any other way to do this?
Merging anonymous types

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:30:45+00:00Added an answer on June 14, 2026 at 7:30 pm

    How about something like this?

    Model:

    public class AViewModel
    {
    
        public string Id1 { get; set; }
        public string Id2 { get; set; }
        public string Id3 { get; set; }
    
        public RouteValueDictionary GetRouteValues()
        {
            return new RouteValueDictionary( new { 
                Id1 = !String.IsNullOrEmpty(Id1) ? Id1 : String.Empty,
                Id2 = !String.IsNullOrEmpty(Id2) ? Id2 : String.Empty,
                Id3 = !String.IsNullOrEmpty(Id3) ? Id3 : String.Empty
            });
        }
    }
    

    View:

    <%: Html.ActionLink("EDIT", "Action", "Controller", Model.GetRouteValues())%>
    

    You can now reuse them as much as you like and only ever have to change them in one place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the need to use a Stack-like data structure for a program that
I have installed Matlab r2010a on my computer I need use the function xlsread
I need to use IBM Informix for my project where I have point coordinates
I need to use something like get_or_create() but the problem is that I have
I have some files that need to use by my application when it is
I need to use the mongo-storm library and Clojars doesn't have it . So
Need to use own imaged markers instead built-in pins. I have several questions. 1.
I have a timed page that I need to use to submit a form
I have a xsl file where i need to use parameters from an external
I have the following problem: I need to use XSLFO to generate a 2-column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.