Working with Html.TexBox and DateTime values.

I am working DateTime value today.  

This doesn’t work.. because the 

wants the DateTime value like “2018-01-01”, so I need to add 

now the whole line look like this

now you can get DateTime value and be able to use the calendar editor that type=“date” provide.

Working on Typeahead

Today, I am working on typeahead with Azure Search.

I am reading, https://docs.microsoft.com/en-us/azure/search/search-autocomplete-tutorial

Before you proceed, you need to make sure you have your suggester fieldset.  Per index, you can have only one suggester field.

On your page use this javascript

This code above uses the jQuery UI Autocomplete library. (https://jqueryui.com/autocomplete/ , see the API here http://api.jqueryui.com/autocomplete/) you can go to https://code.jquery.com/ and find CDN version to simply copy paste to the page.

Now, let’s look at HomeController.cs (or any controller that you set to be called from the javascript)  and related classes to return the suggestions.

/home/suggest?highlihts=false&fuzzy=false needs to return Jason format result.

I actually keep my Azure Search management services in different classes, where I have a method to return a list of suggestions in strings like below.

Then, I have home controller calling this method and return Json as below.

This is it, it works beautifully.

 

 

 

FormExtentions

Mastering form extension is very important because when you are writing modern web services, almost always you will be using form extension to take input from users.  You will be using form extensions frequently for ever, so better master this first.

You can refer to full class documentation here.
https://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.118).aspx

The basic form is like this

which generate html code like below

We usually have two types of forms, one that link to the model and one that is not link to the model.

We will look more into how you can build model that work well with forms later.