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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:28:42+00:00 2026-05-20T17:28:42+00:00

I’ve got a simple ASCX user control (non-MVC). The user control has a property

  • 0

I’ve got a simple ASCX user control (non-MVC). The user control has a property on it (let’s call it Title or something).

I’ve also got an MVC Partial View which contains the user control.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SomeModel>" %>
<%@ Register TagPrefix="tag" TagName="Control" Src="~/path/to/ascx/control.ascx" %>
... snip ...
<tag:Control ID="myControl" runat="server" />

What I’d like to be able to do is something like this:

<tag:Control ID="myControl" runat="server" Title="<%= Model.Title %>" />

… so that I can access some property of the model inside my Control.
Unfortunately this method doesn’t work, as I get a message saying “This is not scriptlet. Will be output as plain text”.

Is what I’m trying to do even possible? If so, does anyone have any ideas how I can try and do it?

If it’s relevant, this is a .Net 4 project, with MVC 2 components.

Thanks!
Neil

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

    Is what I’m trying to do even possible?

    Yes but it would be extremely ugly and it involves using a code behind (in an ASP.NET MVC view!!!):

    <%@ Page 
        Language="C#" 
        MasterPageFile="~/Views/Shared/Site.Master" 
        Inherits="AppName.Views.Home.Index" 
        CodeBehind="Index.aspx.cs" 
    %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        Home Page
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <asp:Label ID="Txt" runat="server" />
    </asp:Content>
    

    and in the corresponding code behind Index.aspx.cs (beurk…, I will vomit):

    public partial class Index : System.Web.Mvc.ViewPage<AppName.Models.MyViewModel>
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Txt.Text = Model.Title;
        }
    }
    

    which could be improved like this to avoid the code behind nonsense:

    <%@ Page 
        Language="C#" 
        MasterPageFile="~/Views/Shared/Site.Master" 
        Inherits="System.Web.Mvc.ViewPage<AppName.Models.MyViewModel>" 
    %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Txt.Text = Model.Title;
        }
    </script>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        Home Page
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <asp:Label ID="Txt" runat="server" />
    </asp:Content>
    

    I wouldn’t recommend you doing something like this if you intend to migrate to ASP.NET MVC 3 and the Razor view engine one day.

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

Sidebar

Related Questions

No related questions found

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.