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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:18:16+00:00 2026-05-22T15:18:16+00:00

the signature for this very useful method states I can indicate a type: public

  • 0

the signature for this very useful method states I can indicate a type:

public static MvcHtmlString EditorFor<TModel, TValue>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression
)

… the docs very understandably state that TModel is “The type of model”. It must be my particular bent that this description conveys no meaning to me whatsoever. I’ve googled for an explanation but found zilch.

I’m in a view where @model Website.Models.Product but want to create an editor for something of a different type. I thought I could:

@Html.EditorFor(@ViewBag.AClassOfTheOtherType)

or maybe (I’m obviously guessing):

@Html.EditorFor(TheOtherType)

but that is not acceptable syntax and so I thought:

@Html.EditorFor(x => x...)

but the lambda expression seems to be bound to @model… so I thought, “ah!”:

@Html.EditoFor<TheOtherType>(...)

but VS thinks the < starts an HTML tag and indicates the end of my EditorFor call (which fails).

aaaaahhhhh!

how do I do this (in case I actually need to ask)?

  • 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-22T15:18:17+00:00Added an answer on May 22, 2026 at 3:18 pm

    the answer is (drumroll please)… yes, one can bind the lambda expression with the type declarator. the only problem is the Visual Studio editor, which thinks one is ending the C# part and entering the HTML part with the opening < and thus disallows proper code. Solution:

    @{ Html.EditoFor<TheOtherType>(...) }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a constructor signature like this public NavigationLink(Func<String> getName, Func<UrlHelper, String> getURL, Func<bool>
I have a method with this signature, and another method that will be the
I have a method with this signature: IEnumerable<string> GetCombinations(string s, int length) And I
In App Engine, according to the JavaDoc , the getTypeRank method has this signature:
i find this question tricky but what files store method signature info for xml
In C++, I find it very useful to add a Clone() method to classes
I have a very weird problem that I can't understand. This is C code:
Duplicate : Function overloading by return type? Maybe this is a very silly question
Referring to this web site http://www.cplusplus.com/reference/std/utility/make_pair/ The std::make_pair has this signature (and possible implementation):
I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target

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.