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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:58:04+00:00 2026-05-23T14:58:04+00:00

I need to create an HtmlHelper extension to render an Autocomplete. Something like this:

  • 0

I need to create an HtmlHelperextension to render an Autocomplete. Something like this:

@Html.AutoCompleteFor(x => x.CustomerId);

The problem is that the Html.RenderPartial(...) returns void, so my AutoCompleteFor method must also be void. But Razor won’t let it compile because @Html.X will only compile if X returns an Object.

I know I can bypass this problem by calling this, instead:

@{ Html.AutoCompleteFor(x => x.CustomerId); }

But that will make my code to look inconsistent with the @Html.EditorFor

I need to return a PartialView from inside my an HtmlHelper

Some considerations:

  • I know you might think that this would be, somehow, breaking the MVC pattern, but MVC itself does that. The Html.EditorFor will try to find a view and return it.
  • I’m only trying to do that because I need foreign-key property to use jQuery-AutoComplete by default. I wasn’t able to tell MVC to use my template for foreign-key properties.
  • 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-23T14:58:05+00:00Added an answer on May 23, 2026 at 2:58 pm

    You should call Html.Partial, which returns a HelperResult object rather than writing directly to the page.
    You can then return the HelperResult to the caller.

    Technically, you could also just return null, but that would be a really dumb idea.

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

Sidebar

Related Questions

I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need create menu for widget like this https://www.gstatic.com/android/market/com.bugabuga.switcher/ss-320-0-0 . What components are used?
UPDATED I am trying to create an HtmlHelper Extension that has the ability to
this is my first post here. I need create a feed like facebook with
I need to create a backup of a SQL Server 2005 Database that's only
<%= Html.EditorFor(product => product.Name) %> I need the generated output to have autocomplete=off attribute
i found XMPP on google (i need create a application IM look like Yahoo
I have this problem. I create two instaces of my classes in main window.
i need to create a HtmlHelperExtension in VB instead of C#. I cannot find
I need to do with HtmlHelper in Controller, so how i create it in

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.