You're using a master page, so the IDs of the controls on the content page will be "mangled". If you view the rendered source of the page, you'll see that there is no element with the ID "ddlNames".
You have two choices:
1) Add
ClientIDMode="Static"
to your control:
<asp:DropDownList ID="ddlNames" runat="server" ClientIDMode="Static"></asp:DropDownList>
Control.ClientIDMode Property (System.Web.UI)[
^]
2) Inject the
ClientID
property into the script:
<asp:DropDownList ID="ddlNames" runat="server"></asp:DropDownList>
<script type="text/javascript">
$(function () {
GroupDropdownlist('<%= ddlNames.ClientID %>');
});
NB: This only works if the script is declared inline. If you move the script to an external
.js
file, it won't work.