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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:07:43+00:00 2026-05-14T21:07:43+00:00

I have a contoller that renders 3 different views. But I also have a

  • 0

I have a contoller that renders 3 different views. But I also have a common part (div) for every view. I thought that I can create an UserControl with own controller and include that control on my views (New controller and view as controll).

How should I use that UserControl? Should it be a partial view?
Or different approach – can I have multiple partial views on one page?

I’ve been searching the web for the last view days and haven’t found working solution that suits me. Also I want to use Strongly Typed views/data.

Cheers

  • 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-14T21:07:44+00:00Added an answer on May 14, 2026 at 9:07 pm

    You should use a partial view. Then you call <% Html.PartialRender("MyCommonControl", Model); %> in the 3-4 views to render the common section (like a menu or something).

    This way you can strongly type the partial view and pass the model (like in the above example) or part of the model to it that is relevant.

    UserControls are a ASP.NET Forms paradigm really, you should use partial views because they use the same MVC View Engine.

    Update

    If you place the PartialView in /Views/Home it’ll only be accessible to the HomeController You want to put it in /Views/Common to make it accessible to ALL controllers.

    You should also make a Generic ViewModel for The data that control needs, and make it a sub-component of the models for each Controller:

    Eg:

    class CommonSectionViewModel
    {
        public string Data { get; set; } // Just Example Data
        public int Count { get; set; }
    }
    
    class ProductsModel
    {
        public CommonSectionViewModel CommonData { get; set; }
        // Other properties for a products models
    }
    
    class CompaniesModel
    {
        public CommonSectionViewModel CommonData { get; set; }
        // Other properties for a company model
    }
    

    Then in your Views for your controllers you call the partial render like this:

    <% Html.PartialView("MyCommonControl", Model.CommonData); %>
    

    Note: You can override the control as well

    Having the following files:

    1. /Views/Common/MyCommonControl.ascx
    2. /Views/Products/MyCommonControl.ascx

    When you call .RenderPartial("MyCommonControl") from ProductsController #2 is used, and from any other controller, #1 is used. So you can override functionality for some controllers if you wish.

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

Sidebar

Related Questions

I have a template that exists under views/dashboard/_myTemplate.gsp and from the DashboardController I can
Imagine you have a secured site and a View that can be generated in
I have a page (Controller Action that renders a View) that a user could
Say I have a partial view that renders a dropdown list of Applications. When
I have a view controller that houses a UIWebView. I want to display an
I am trying to test my views with RSpec. The particular view that is
I have a controller setup that uses a whole bunch of different AjaxContent helpers.
I have a controller that looks like this: public class PageController : Controller {
I have a controller that runs some calculation on data, and then I need
I have a controller that contains a tableView that spawns another controller modally to

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.