Search results

Close the popup on scroll in ASP.NET Core DropDownList control

08 Dec 2021 / 1 minute to read

By using the hidePopup method in DropDownList, you can close the popup on scroll when triggered the windows scroll event.

The following example demonstrate about how to close the popup on scroll.

Copied to clipboard
<div class="control-wrapper">
    <div id="default" style='padding-top:75px;'>
        <ejs-dropdownlist id="games" dataSource="" placeholder="Select a game" index="2" popupHeight="220px">

    document.onscroll = () => {
        var dropObj = document.getElementById("games"); //to get dropdown list object
        dropObj.ej2_instances[0].hidePopup(); // hide the popup using hidePopup method
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
    public class DropDownListController : Controller
        public IActionResult closepopup()
   = new string[] { "American Football", "Badminton", "Basketball", "Cricket", "Football", "Golf", "Hockey", "Rugby", "Snooker", "Tennis" };
            return View();