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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:52:52+00:00 2026-05-22T00:52:52+00:00

How can I get access to the HTML extensions …For like LabelFor, EditorFor, ValidationMessageFor

  • 0

How can I get access to the HTML extensions …For like LabelFor, EditorFor, ValidationMessageFor

I’m writing my own extension like that

Imports System
Imports System.Web.Mvc
Imports System.Web.Mvc.Html
Imports System.Web
Imports System.Text

Public Module HtmlExtensions
    <System.Runtime.CompilerServices.Extension()> _
    Public Function Asistente(Of TModel As Class)(ByVal helper As HtmlHelper, model As TModel) As MvcHtmlString
        helper.ValidationMessage("Home") 'It works fine
        helper.ValidationMessagefor()    'It show the next message 'ValidationMessagefor' is not a member of 'System.Web.Mvc.HtmlHelper     
    End Function

...

Actually it’s because I want to produce a mvcHtmlString like that

<div class="editor-label">
    @Html.LabelFor(Function(model) model.Numero)
</div>
<div class="editor-field">
    @Html.EditorFor(Function(model) model.Numero)
    **@Html.ValidationMessageFor(Function(model) model.Numero)**
</div>
  • 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-22T00:52:53+00:00Added an answer on May 22, 2026 at 12:52 am

    The ValidationMessageFor method requires a generic type html helper. So your method should probably look something like this:

    Public Shared Function Asistente(Of TModel, TProperty)(helper As HtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TProperty))) As HtmlString
        Return helper.ValidationMessageFor(expression)
    End Function
    

    This will allow you to use that extension for any model and your call wouldn’t change. I’m not entirely sure of what you’re asking though.

    **@Html.Asistente(Function(model) model.Numero)**
    

    (note that vb was produced using a c# to vb converter – but it looks right)

    If you want to use the first sample you posted then you’re going to have to write it something like this:

    Public Shared Function Test(Of T As User)(helper As HtmlHelper(Of T), model As T) As HtmlString
        Return helper.ValidationMessageFor(Function(f) f.Name)
    End Function
    

    However, that’s a specific use case because if you don’t force the model type to a specific type then you won’t get the lambda expression properties to show up and thus won’t compile.

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

Sidebar

Related Questions

Is there any really low level programming language that can get access the memory
I'd like to have access to one my model field verbose_name. I can get
I'd like to get the HTML for a MediaWiki Page, that is I want
How can I get programmatic access to the call stack?
I have a database which is in Access (you can get it link text
How can I get the BSSID / MAC (Media Access Control) address of the
How can I get the field names of an MS Access database table? Is
I can't seem to get a simple program (with lots of memory access) to
I'm trying to access a member structs variables, but I can't seem to get
I want to access the raw HTML code that my ASP.NET System.Web.UI.Page is about

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.