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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:57:31+00:00 2026-05-15T02:57:31+00:00

I know they now have this in ASP.NET MVC 2.0 <%: Model.CustomerName %> So

  • 0

I know they now have this in ASP.NET MVC 2.0 <%: Model.CustomerName %>

So when you make HTML helpers is it better to use this way now (provided that you do not want to do HTML encoding)?

  • 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-15T02:57:31+00:00Added an answer on May 15, 2026 at 2:57 am

    Yes, you always want to use <%: Model.CustomerName %> from now on where you can. Only in very specific cases should you use <%= %> but try not to use it at all.

    If you are creating your own html helpers that you don’t want to be encoded, then just return a MvcHtmlString from them.

    E.g. This is a extension method I created to display a tick icon if the passed in value is true.

    public static MvcHtmlString MECross(this HtmlHelper html, string value, string text)
    {
        if (Convert.ToBoolean(value))
        {
            string spanTag = string.Format("<span class=\"replace icon-cross\" title=\"{0}\"><em></em>{1}</span>",
                                            html.AttributeEncode(text),
                                            html.Encode(text));
    
            return MvcHtmlString.Create(spanTag);
        }
    
        return MvcHtmlString.Empty;
    }
    

    Note that I Encode and AttributeEncode anything that could be dangerous in my extension method and then return a MvcHtmlString.

    HTHs,
    Chares

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

Sidebar

Related Questions

I am using asp.net mvc and I am not sure how to approach this
I have a very simple asp.net mvc web app which uses castle active record,
The behavior described here appears to now be the default for ASP.NET MVC 2
I have an ASP.NET MVC application. In the application, I have a bunch of
Since asp.net mvc did away with many controls that were in webforms, does this
I have used LINQ-to-SQL in WPF and ASP.NET MVC projects in the following way:
We have a website which we recently migrated to ASP.NET MVC. All of the
I have written an ASP.NET MVC application that allows the user to specify their
I have come across quite a wired problem right now. I am using ASP.NET
I know they are bad practice but I have a real need on an

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.