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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:32:01+00:00 2026-05-11T16:32:01+00:00

I am refactoring a web app built with previous versions of Asp.Net MVC where

  • 0

I am refactoring a web app built with previous versions of Asp.Net MVC where all the views have 2 codebehind files each.

Also if the views are working correctly I want to begin to remove all the code behind files as most of them are empty.

There are few of them that have properties like this in the codebehind:

public partial class List {
    public Message NewMessage { get { return new Message(); } }
}

Before completely removing them (I know this methods do not pertain to the views) how do I replicate them in the single page aspx or ascx?
I just tried to copy and paste the public methods in <% %> tags but this is not working.

  • 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. Editorial Team
    Editorial Team
    2026-05-11T16:32:01+00:00Added an answer on May 11, 2026 at 4:32 pm

    May I ask why you were using this approach in the first place? I think you could achieve the same thing by making your View strongly typed, and pass the message as the View‘s Model.

    Inherits="System.Web.Mvc.View<Message>"
    

    If you already have a strongly typed View, you could make a custom class in your class library that has room for your message, for example

    public class ModelWithMessage  {
        public Message Message { get; set; }
        public Object Model { get; set; }
        public ModelWithMessage(Message Message, Object Model) {
            this.Message = Message;
            this.Model = Model;
        }
    }
    

    You can of course make that type generic as well, allowing for a ModelWithMessage<T> construct and avoiding having to cast the Model to whatever type you need.

    Another way to do it would be to use TempData. In your Controller, set

    TempData["Message"] = "Hello world!";
    

    Then in your View you write the message out simply with

    <%= TempData["Message"] %>
    

    Which approach you choose depends on what your Message class contains.

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

Sidebar

Related Questions

I've been tasked with porting/refactoring a Web Application Platform that we have from ASP.NET
I have done some refactoring on a asp.net mvc application already deployed to a
I have an ASP.net Web Site Project (.net 3.5). Currently all of the non-code
I was dealing with refactoring of my small web app. all night. Today when
I have a large web app in vb.net 4.0. Its default namespace is configured
I'm building a simple game in an ASP.NET/VB.NET web app. The game has a
I have a Crystal Report used in an ASP.NET web application that I've just
I'm trying to refactor an existing asp.net-mvc web application and introduce mvc-turbine. The application
I am refactoring a working ASP.NET Web Application to expose Web Services interface using
I am currently refactoring my code for a web application developed using ASP.NET MVC3

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.