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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:30:35+00:00 2026-06-06T13:30:35+00:00

System.Web.Mvc has an HtmlHelper that contains a method called EditorFor that renders the editing

  • 0

System.Web.Mvc has an HtmlHelper that contains a method called EditorFor that renders the editing control associated with a data type in a view.

Im trying to create my own EditorFor method by extending the ASP.NET MVC 2 HtmlHelper. I have the following:

    public static string EditorForNew<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> item)
    {
        string value = "";
        string name = item.ToString(); // THIS IS CORRECTED IN MY COMMENT TO THE ANSWER BELOW!
        Type type = typeof(TProperty);

        if (type == typeof(int) || type == typeof(int?) || type == typeof(double) || type == typeof(double?) || type == typeof(decimal) || type == typeof(decimal?) || type == typeof(float) || type == typeof(float?))
        {
            return helper.TextBox(name, value, new { @class = "number" }).ToString();
        }
        else
        {
            return helper.TextBox(name, value).ToString();
        }
    }

Can anyone explain how I retrieve the VALUE of the object’s property that is passed to this from the view?

  • 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-06-06T13:30:36+00:00Added an answer on June 6, 2026 at 1:30 pm

    You need to use a ModelMetadata:

    ModelMetadata metadata = ModelMetadata.FromLambdaExpression(item, helper.ViewData);
    

    You can then get the value from the metadata.Model property.

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

Sidebar

Related Questions

I got a view that inherits : System.Web.Mvc.ViewPage<IEnumerable<MyProjects.Models.MyAccountWrapper>> In this view I list data
CS1928: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'DropDownList' and the best extension method
Does omebody has ideas how to fix Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary,
What is wrong with this statement? I`m having the following error: Error 10 'System.Web.Mvc.HtmlHelper'
If my base class has something like: using System.Web.Mvc; using System.Web.Routing; using MFA.Storage.Helpers; using
Below is my asp mvc view. Note that it has a div which contains
I have this infoflyout.ascx <%@ Control Language=C# Inherits=System.Web.Mvc.ViewUserControl<dynamic> %> <script type=text/javascript> $(document).ready(function () {
I have a System.Web.Mvc.RazorView object which is strongly typed when in cshtml. Can I
Thanks to MSDN, they don't explain anything about it: http://msdn.microsoft.com/en-us/library/system.web.mvc.async.asyncmanager.outstandingoperations(v=vs.108).aspx Can somebody please explain
I've built a custom login system for my asp.net mvc 1.0 web application as

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.