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 743823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:54:28+00:00 2026-05-14T08:54:28+00:00

I have a dictionary I’m passing to a View. I want to be able

  • 0

I have a dictionary I’m passing to a View. I want to be able to pass the values of that dictionary back to a Controller action from this same View. Is there anyway this can be accomplished without using a form? The situation is that I need to be able to pass these back to a controller action that is called when a user clicks an ActionLink from the View, and in my experience an ActionLink cannot be used to submit a values of a form, i.e. I’ve only been able to submit values of a form using the form’s submit button. Unless there’s a way to use an ActionLink to submit values in a form.

Controller Action passes Dictionary to Controller in ViewData:

public ActionResult ModifyNewCrossListing(FormCollection form)
        {
            Dictionary<int, string> prefixlist = new Dictionary<int, String>();
            ViewDatap["prefixList"] = prefixlist;
        }

View prints out content of Dictionary, ActionLink calls another controller action, which is where I want to access the dictionary:

<%int i = 0;
      if ((ViewData["prefixList"] as Dictionary<int, string>).Count >= 1)
      {
          foreach (var cp in (ViewData["prefixList"] as Dictionary<int, string>))
          {
              if (cp.Value == (ViewData["prefixList"] as Dictionary<int, string>).Last().Value)
              {%>
                  <%= Html.Encode(cp.Value)%>
              <%}
              else
              {%>
                  <%= Html.Encode(cp.Value)%> -
            <%}
          } 
      } %> 

<%=Html.ActionLink("View All Criteria", "ShowAllCriteria", new { prefixList = ViewData["prefixList"] as Dictionary<int, string> })%>)

And finally, in my new controller action, I want to be able to access the dictionary

public ActionResult ShowAllCriteria(Dictionary<int, string> prefixList)
        {
          //Do stuff
        }
  • 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-05-14T08:54:28+00:00Added an answer on May 14, 2026 at 8:54 am

    Without a button or form, I would say that your best bet is to hook the link to a Javascript or jQuery method, and post the data back to the controller using AJAX or JSON.

    The controller method can then perform the necessary redirect to display a new page.

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

Sidebar

Related Questions

I want to have Dictionary that would be 'Observable' in order to throw events
I have a Dictionary Byte, Char ASCIIlist that I want to populate with the
I have C# Dictionary and I want create a .csv file from it. For
I have Dictionary from string key i want to get Value of corresponding key
Suppose I have Dictionary like this: Dictionary<string, string> values = new Dictionary<string, string>() {
I have a dictionary object called obj_1 and it's values are shown like this:
I have dictionary that gives me back a method according to the value passed
I have a dictionary of type Dictionary<int, double> and want to eliminate values equal
Have Dictionary <Int64, byte> that gets used a lot. I mean in a loop
I have dictionary, like Dictionary<string, bool> accValues = new Dictionary<string, bool>() And I want

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.