ASP.NET MVC ListBox - Client-Side API - Enable / Disable

  • Alfreds FutterkisteALFKI
  • Antonio Moreno TaqueríaANATR
  • Around the HornAROUT
  • Berglunds snabbköpANTON
  • Berglunds snabbköpBERGS
  • Blauer See DelikatessenBLAUS
  • Blondesddsl père et filsBLONP
  • Bólido Comidas preparadasBOLID
  • Bon app'BONAP
  • Bottom-Dollar MarketsBOTTM
   
Enable
 
Disable
The ListBox control provides client-side methods for enabling / disabling the control.

Use the enable client-side method to enable the ListBox.
Use the disable client-side method to disable the ListBox.
View - Aspx

    <% Html.Obout(new ListBox("ListBox1")
    {   
        Width = Unit.Pixel(300),
    }); %>
    
    <% Html.Obout(new OboutButton("OboutButton1")
    {
        OnClientClick = "return enableListBox();"
    }); %>
    
    <% Html.Obout(new OboutButton("OboutButton2")
    {
        OnClientClick = "return disableListBox();"
    }); %>	   
    
    
View - Razor

    @Html.Obout(new ListBox("ListBox1")
    {   
        Width = Unit.Pixel(300),
    })
    
    @Html.Obout(new OboutButton("OboutButton1")
    {
        OnClientClick = "return enableListBox();"
    })
    
    @Html.Obout(new OboutButton("OboutButton2")
    {
        OnClientClick = "return disableListBox();"
    })
    
    
JavaScript

    function enableListBox() {
        ListBox1.enable();

        return false;
    }

    function disableListBox() {
        ListBox1.disable();

        return false;
    }