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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:23:12+00:00 2026-05-11T01:23:12+00:00

I have developed a simple mechanism for my mvc website to pull in html

  • 0

I have developed a simple mechanism for my mvc website to pull in html via jquery which then populates a specified div. All is well and it looks cool.
My problem is that i’m now creating html markup inside of my controller (Which is very easy to do in VB.net btw) I’d rather not mix up the sepparation of concerns.

Is it possible to use a custom ‘MVC View User Control’ to suit this need? Can I create an instance of a control, pass in the model data and render to html? It would then be a simple matter of rendering and passing back to the calling browser.

  • 1 1 Answer
  • 3 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. 2026-05-11T01:23:13+00:00Added an answer on May 11, 2026 at 1:23 am

    You have several options.

    Create a MVC View User Control and action handler in your controller for the view. To render the view use

    <% Html.RenderPartial('MyControl') %> 

    In this case your action handler will need to pass the model data to the view

    public ActionResult MyControl () {     // get modelData      render View (modelData); } 

    Your other option is to pass the model data from the parent page. In this case you do not need an action handler and the model type is the same as the parent:

    <% Html.RenderPartial('MyControl', ViewData.Model) %> 

    If your user control has it’s own data type you can also construct it within the page

    In MyControl.ascx.cs:

    public class MyControlViewData {     public string Name { get; set; }     public string Email { get; set; } }  public partial class MyControl : System.Web.Mvc.ViewUserControl <MyControlViewData> { } 

    And in your page you can initialize your control’s data model:

    <% Html.RenderPartial('MyControl', new MyControlViewData ()    {         Name= ViewData.Model.FirstName,         Email = ViewData.Model.Email,    });  %> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a simple location aware iPhone application which is functionally working very
I have developed a simple C# Winforms application that loads MS-Word 2007 documents via
I have developed a simple utility for my iPhone and iPad apps which places
I have developed a simple website using HTML5 and CSS3. I had lots of
I have developed simple website using Tomcat and Java. Now I'm trying to add
I have developed a simple batch file which I want to set up as
I have developed a simple NFC app which will launch after sensing the NFC
I have developed a simple application using SDK(Android: 3.2[API-13]) for, to display Google banners.
I have developed a simple library in Ruby and need to use this in
I am new to rails and have developed a simple rails application on my

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.