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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:00:39+00:00 2026-05-14T17:00:39+00:00

I have ascx partial view with html-layout like that <%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, …

  • 0

I have ascx partial view with html-layout like that

<%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ... )) %>

My ascx is pretty big & I’d like to reuse it, changing controller/method in Html.ActionLink with another controller/method. Method of another controller has the same signature as PersonController.Publications. Please, suggest me the best way how to make controller/method configurable for my layout.

Thank you in advance

  • 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-14T17:00:40+00:00Added an answer on May 14, 2026 at 5:00 pm

    The easiest way would be to have the controller name and action name as strings on your model. Then you could use the non strongly typed overload of actionlink. Something like this:

    <%=Html.ActionLink(Model.Action, Model.Controller, new { param1 = 1, param2 = 2 })%>
    

    And use it like this:

    <%Html.RenderPartial("PartialName", new PartialModel{Controller = "Person", Action = "Publications"})%>
    

    If you want to use the strongly typed version you can do something like this:

    //Model for your partial view
    public class PartialModel<TController> where TController : Controller
    {
        public Func<int, int, Expression<Action<TController>>> GetLinkAction { get; set; }
    }
    
    //Render the action link in your partial
    <%=Html.ActionLink(Model.GetLinkAction(1, 2))%>
    
    //Render the partialview in any page
    <%Html.RenderPartial("PartialName", new PartialModel<PersonController> { GetLinkAction = (param1, param2) => x => x.Publications(param1, param2) })%>
    

    You will of course have to adjust this for the parameters that you have. The nice thing about the strongly typed way is that the methods doesn’t have to have the exact same signature and parameter names.

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

Sidebar

Related Questions

I have a partial view called StudentInfo.ascx. In it I have something like this:
I have a strongly typed partial view CheckBox.ascx that renders a checkbox. This is
I have a partial view that returns an HTML chunk of list items that
I have a view that calls on four different partial views (.ascx) to populate
In my forum project I have a partial view (.ascx) that is used for
I have an ascx that uses Eval in a repeater like this: <%@ Control
I am editing and have already saved a Vendor.ascx partial view in VS 2010.
I have a view: User. In that I have an ascx page : Details
I Have 2 views. ProductForm.aspx and Category.ascx. CategoryForm is a Partial View. I Call
I have a ViewPage , Index.aspx. In it, I have: <%= Html.Partial(~/Index/ViewUserControl/Promo.ascx, new PromoViewModel());

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.