Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142028 | Jan 15,2019 08:24 PM UTC | Sep 13,2019 10:26 AM UTC | ASP.NET Core - EJ 2 | 7 |
![]() |
Tags: Dropdown List |
[cshtml]
<form id="dropdownsform" method="post">
<div class="form-group">
<div>
<ejs-dropdownlist id="DropTitle" ejs-for="DropTitle" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px">
</ejs-dropdownlist>
<span asp-validation-for="DropTitle" class="text-danger"></span>
</div>
</div>
<input type="submit" value="submit" class="e-control e-btn"/>
</form>
[cs]
public IActionResult Index()
{
ViewBag.data = new string[] { "Badminton", "Basketball", "Cricket", "Football", "Golf", "Gymnastics", "Hockey", "Tennis" };
return View();
}
public class Annotation
{
[Required(ErrorMessage = "DropDownList value is required")]
public string DropTitle { get; set; }
}
|
public IActionResult PostExample(Annotation annotation)
{
if (!ModelState.IsValid)
{
ViewBag.data = new List<Test> { new Test { Id = 1, Name = "Name-1" }, new Test { Id = 2, Name = "Name-2" } };
return View("index");
}
return View("index");
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.