I want to load an external Json data File which contain the city name of a country.I want to show it in the search option in Index.cshtml.My Json file look like this-
CityName[
{
"City": "Flensburg"
},
{
"City": "Kiel"
},
{
"City": "Lübeck"
},
{
"City": "Neumünster"
}
]
Now I created City class inside the Model to get the name from this object.
public class City
{
public string City { get; set; }
}
My Controller Class look like this-
public class HomeController : Controller
{
public ActionResult Search(string name)
{
return View();
}
}
Now for the view I used Javascript and created one search box with button like this-
<div class="search-form">
<form action="index.html" method="get">
<div class="input-group">
<input type="text" placeholder="Enter Location Name" name="search" class="form-control input-lg">
<div class="input-group-btn">
<button class="btn btn-lg btn-primary" type="submit">
<a href="@Url.Action("Search", "Home")">Search</a>
</button>
</div>
</div>
</form>
</div>
Now I want to set the city name in the search option. But as I am very new in handling MVC, I am not sure how to proceed with it.