Can I see a code sample to remove all WDD items via client-side javascript?
Thanks.
Hello johnvrsm,
The code that you can use to clear items on Client-Side is shown below:
<ig:WebDropDown ID="WebDropDown2" runat="server" Width="200px"> <Items> <ig:DropDownItem Selected="False" Text="Item0" Value="0"> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="Item1" Value="1"> </ig:DropDownItem> <ig:DropDownItem Selected="False" Text="Item2" Value="2"> </ig:DropDownItem> </Items> </ig:WebDropDown> <input id="Button2" type="button" value="Clear Items" onclick="clearDDItems()" /> <script type="text/javascript"> function clearDDItems() { var dropdown = $find("WebDropDown2"); dropdown._elements["List"].innerHTML = ''; dropdown.set_currentValue("", true); } </script>
<ig:WebDropDown ID="WebDropDown2" runat="server" Width="200px">
<Items>
<ig:DropDownItem Selected="False" Text="Item0" Value="0">
</ig:DropDownItem>
<ig:DropDownItem Selected="False" Text="Item1" Value="1">
<ig:DropDownItem Selected="False" Text="Item2" Value="2">
</Items>
</ig:WebDropDown>
<input id="Button2" type="button" value="Clear Items" onclick="clearDDItems()" />
<script type="text/javascript">
function clearDDItems() {
var dropdown = $find("WebDropDown2");
dropdown._elements["List"].innerHTML = '';
dropdown.set_currentValue("", true);
}
</script>
This code will clear the items from the dropdown but since this is a Server control to remove items entirely you will have to clear items from Server collection also.
Thanks this worked.