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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:29:51+00:00 2026-05-19T06:29:51+00:00

I am working on a ASP.NET MVC2 website. For learning. I am working with

  • 0

I am working on a ASP.NET MVC2 website. For learning. I am working with the Visual Basic language.

In a view I would like to do this:

 <%: Html.EditorForEnumeracion(Function(v) v.combustible%>

So, I created an HtmlHelper extension method:

Imports System.Runtime.CompilerServices
Imports System.Linq.Expressions
Imports System.Reflection

Public Module HtmlHelpers
    <Extension()> _
    Public Function EditorForEnumeracion(Of TModel, TValue)(ByVal html As HtmlHelper(Of TModel), ByVal expression As Expression(Of Func(Of TModel, TValue))) As MvcHtmlString
        'My stuff goes here
     End Function
End Module

The problem is that I do not know how to get the instance of the v.combustible object that I pass to the helper. I do not care about the v object. I need to work with the combustible attribute of the v object.

Here and here seems to be how to do this, but I do not understand. Also, I work with Visual Basic, not C#.

I think that I can get the instance of the Enumeracion object through the expression parameter, but I do not understand how.

More info now.

This is my “Vehiculo” class:

Namespace Models.Automovil
    Public Class Vehiculo
        Public Property tipo As New Models.Enumeracion("TipoDeVehiculo")
        Public Property marca As String
        Public Property modelo As String
        Public Property numeroDePuertas As Integer
        Public Property combustible As New Models.Enumeracion("TipoDeCombustible")
        Public Property potencia As Integer
        Public Property fechaPrimeraMatriculacion As DateTime
        Public Property version As String
        Public Property precio As Decimal
        Public Property descripcion As String
    End Class
End Namespace

And this is my “Enumeracion” class:

Namespace Models
    Public Class Enumeracion
        Private bd As New tarificadorasegasaEntities
        Private diccionario As New Dictionary(Of String, Integer)
        Private _nombre As String
        Private _clave As String
        Private _valor As Integer
        Public ReadOnly Property nombre As String
            Get
                Return _nombre
            End Get
        End Property
        Public ReadOnly Property clave As String
            Get
                Return _clave
            End Get
        End Property
        Public ReadOnly Property valor As Integer
            Get
                Return _valor
            End Get
        End Property

        'More stuff here. Methods.

    End Class
End Namespace

The model is the Vehiculo class.

Still not resolving this.

Thanks in advance.

  • 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-19T06:29:53+00:00Added an answer on May 19, 2026 at 6:29 am

    Try like this:

    <Extension()> _
    Public Function EditorForMyCustomClassB(Of Vehiculo, Enumeracion)(ByVal html As HtmlHelper(Of TModel), ByVal expression As Expression(Of Func(Of Vehiculo, Enumeracion))) As MvcHtmlString
        Dim res = ModelMetadata.FromLambdaExpression(expression, html.ViewData)
        Dim e As Enumeracion = DirectCast(res.Model, Enumeracion)
        ' use e here
     End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.net MVC2 website that was working great when using Visual Studio
I am currently working on an ASP.NET MVC2 project. This is the first time
I've been working with ASP.NET MVC for the last few weeks, learning as I
I am working with asp.net website project that some of pages need authentication. I
I'm working on an ASP.NET website which targets desktop browsers. We want to enable
I am working on a ASP.NET MVC 2.0 Multi-Presentation web application which would use
In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working
How do I make a static link in a view? (using ASP.NET MVC2) I
Currently I'm working on an ASP.NET MVC 2 website. Company policy says that as
I'm working on an ASP.Net MVC2 application and use the jsTree-Komponent for jQuery to

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.