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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:19:59+00:00 2026-05-30T18:19:59+00:00

I use a helper method to create sections in my view: @helper CreateFacetSection(WebViewPage page,

  • 0

I use a helper method to create sections in my view:

@helper CreateFacetSection(WebViewPage page, string sectionName,
                           List<FacetValue> model)
{
     var showMore = int.Parse(WebConfigurationManager.AppSettings["ShowMore"]);

     <section id="@sectionName">

     <h4>@sectionName</h4>

        <ul>
            @for (int i = 0; i < model.Count(); i++)
            {
                if (i >= showMore)
                {
                    @:<li class="hide">
                }
                else
                {
                    @:<li>
                }

                FacetValue fv = model.ElementAt(i);

                @page.Html.ActionLinkWithQueryString(fv.Range, "Search",
                                              new { sectionName = fv.Range }, null);

                @:(@fv.Count)

                @:</li >
            }
        </ul>   

        @if(model.Count > showMore)
        {
            <a href="#" class="show-more" data-section="@sectionName">
            @Localization.ShowMore &#9660;</a>
        }   

     </section>
}

Now let’s say I have this custom @Html.ActionLink helper used in the helper above:

 @Html.ActionLinkWithQueryString(fv.Range, "Search", new { sectionName = fv.Range });

Is there any way of passing a dynamic named parameter in the route value collection? In the case above I’d like to have a parameter sectionName dynamically named so that I’d get the correct value bound in the action method. It would vary according to the sectionName I’m currently passing as parameter to the helper method…

Right now I’m getting a link like this:

http://leniel-pc:8083/realty/search?sectionName=Volta%20Redonda

It should be:

http://leniel-pc:8083/realty/search?City=Volta%20Redonda

City or whatever I pass as parameter instead of sectionName because “City” is the value of the parameter sectionName I’m passing to the helper method.

I could do a switch for sectionName but I’m just wondering if there’s a neater way of achieving this.

  • 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-30T18:20:00+00:00Added an answer on May 30, 2026 at 6:20 pm

    You haven’t shown how the ActionLinkWithQueryString custom helper looks like but you could add an overload which takes a RouteValueDictionary instead of an anonymous object. And then it’s easy:

    var values = new RouteValueDictionary();
    values["somedynamicname"] = "some dynamic value";
    values["someotherdynamicname"] = "some other dynamic value";
    

    and then:

    @Html.ActionLinkWithQueryString(fv.Range, "Search", values);
    

    Since you said that this is an extension method using ActionLink internally, there are overloads of ActionLink that take RouteValueDictionary instead of an anonymous object as route parameter.

    And since RouteValueDictionary has a constructor that takes a IDictionary<string, object> it could be very easy to build it using LINQ from your model.

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

Sidebar

Related Questions

I use special method to create sandobx: internal static class Helper { public static
I know I can use the ActionView helper strip_tags method in my views to
Is there any way to use a Rails helper method, more specifically, a path
I'm new to Rails, and I'm trying to use the link_to helper to create
I am used to use the helper methods link_to_remote and friends to create links
I want create a helper class that containing method like cleanArray, split_char, split_word, etc.
It's a little unclear for me on when to use a custom helper method
I believe that I'm going to need to use an html helper method that
I have a few 'helper' style extension methods I use quite regularly now (they
It looks like you cannot use a helper in a controller even if both

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.