Example of Inline in ASP.NET MVC DropDownList Control
The DropDownList appearing in line with highlighted content. Click that DropDownList value content and select an item from the popup list.
React top expert of this week is
@Html.UiDropDownList("inline", new UiDropDownListOptions
{
Placeholder = "Select an employee",
PopupWidth = "140px",
CssClass = "ui-dd-inline",
PopupHeight = "200px",
Width = "65px",
Value = "Michael",
DataSource = (IEnumerable<DropdownsDemoController.InlineEmployees>)ViewData["data"],
Fields = new UiDropDownFields { Text = "Name" }
})
<style>
.control-wrapper { margin: 0 auto; width: 325px; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section" style="height: 400px;">
<div class="control-wrapper">
<div style="padding-top:75px;">
<span id="contentText" style="font-size: 14px;">
React top expert of this week is
@Html.UiDropDownList("inline", new UiDropDownListOptions
{
Placeholder = "Select an employee",
PopupWidth = "140px",
CssClass = "ui-dd-inline",
PopupHeight = "200px",
Width = "65px",
Value = "Michael",
DataSource = (IEnumerable<DropdownsDemoController.InlineEmployees>)ViewData["data"],
Fields = new UiDropDownFields { Text = "Name" }
})
</span>
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class DropDownListController : Controller
{
// The page is Views/DropDownList/Inline.cshtml; it draws what ViewData holds.
public ActionResult Inline()
{
ViewData["data"] = new InlineEmployees().EmployeesList();
return View();
}
public class InlineEmployees
{
public string Name { get; set; }
public string Eimg { get; set; }
public List<InlineEmployees> EmployeesList()
{
List<InlineEmployees> emp = new List<InlineEmployees>();
emp.Add(new InlineEmployees { Name = "Andrew", Eimg = "7" });
emp.Add(new InlineEmployees { Name = "Anne", Eimg = "1" });
emp.Add(new InlineEmployees { Name = "Janet", Eimg = "3" });
emp.Add(new InlineEmployees { Name = "Laura", Eimg = "2" });
emp.Add(new InlineEmployees { Name = "Michael", Eimg = "9" });
emp.Add(new InlineEmployees { Name = "Nancy", Eimg = "4" });
emp.Add(new InlineEmployees { Name = "Robert", Eimg = "8" });
emp.Add(new InlineEmployees { Name = "Steven", Eimg = "10" });
return emp;
}
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The DropDownList component can be rendered in line with other content and you can override the styles of the dropdownlist component.
This sample illustrates using the user's data that has been used and customized DropDownList border.