In Winforms, you can set AutoComplete settings, much like in Youtube where you type "timc" and it suggests a bunch of values (like "TimCast") you can pick from. It's not a dropdown, as you can still type stuff that isn't in our dear digital overlord's preferred
path.
Is there a way to add autocomplete to an MVC form edit fields? There must be some way to viewbag a list and then, what? Maybe there's a special form of @Html.EditorFor that allows for this?
I'd rather live with false hope than with false despair.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
As suggested above, autocomplete requires a JavaScript code. The list can be rendered on the page as a JavaScript mapped object via json, or it can be an Ajax call.
there are literals dozens of autocomplete libraries. Before picking one you should decide how many JavaScript components you will need. Are you using a css framework like bootstrap. In which you want components compatible with that framework.
html forms support text boxes, checkboxes, and drop down lists, no combo and a post back button. If your UI is more complex then fill in a form, simple validation and post, then you will probably need a lot of JavaScript. You should review some of the JavaScript
frameworks.
it you are trying to replicate a winform application you most likely will need a lot of JavaScript. If this is the case you may want to write a progressive JavaScript app.
Member
256 Points
323 Posts
Help And Fill (AutoComplete) in edit fields
May 05, 2020 05:37 PM|some_yahoo|LINK
In Winforms, you can set AutoComplete settings, much like in Youtube where you type "timc" and it suggests a bunch of values (like "TimCast") you can pick from. It's not a dropdown, as you can still type stuff that isn't in our dear digital overlord's preferred path.
Is there a way to add autocomplete to an MVC form edit fields? There must be some way to viewbag a list and then, what? Maybe there's a special form of @Html.EditorFor that allows for this?
Member
170 Points
49 Posts
Re: Help And Fill (AutoComplete) in edit fields
May 05, 2020 05:57 PM|vitomanj|LINK
I did build an auto-suggest from scratch using 3 methods in my ultimate dropdown series for ASP.NET MVC.
https://www.danylkoweb.com/Blog/the-ultimate-guide-to-aspnet-mvc-dropdowns-JO
I'm hoping this fits your requirement.
JD
Contributor
2750 Points
781 Posts
Re: Help And Fill (AutoComplete) in edit fields
May 06, 2020 03:29 AM|YihuiSun|LINK
Hi, some_yahoo
You can use jQuery UI to fulfill your needs.I made an example for you, you can refer to it.
Controller
public ActionResult AutoFillEditorPage() { return View(); } public ActionResult AutoFillEditor(string Name) { return Json(db.Users.Where(u => u.Name.StartsWith(Name)).Select(u => new { label = u.Name}).ToList(), JsonRequestBehavior.AllowGet); }
Page
Here is the result.
Best Regards,
YihuiSun
All-Star
58204 Points
15661 Posts
Re: Help And Fill (AutoComplete) in edit fields
May 06, 2020 02:39 PM|bruce (sqlwork.com)|LINK
As suggested above, autocomplete requires a JavaScript code. The list can be rendered on the page as a JavaScript mapped object via json, or it can be an Ajax call.
there are literals dozens of autocomplete libraries. Before picking one you should decide how many JavaScript components you will need. Are you using a css framework like bootstrap. In which you want components compatible with that framework.
html forms support text boxes, checkboxes, and drop down lists, no combo and a post back button. If your UI is more complex then fill in a form, simple validation and post, then you will probably need a lot of JavaScript. You should review some of the JavaScript frameworks.
it you are trying to replicate a winform application you most likely will need a lot of JavaScript. If this is the case you may want to write a progressive JavaScript app.