I'm trying to check if a list item (LI) exists in an unfiltered list (UL). I want to check this by the list item ID.
I am doing this to check if a drag and drop item still exists in the list
i.e. Does LI1 exist in Sortable1
<ul id="sortable1" runat="server" class="connectedSortable">
<li id="LI1" runat="server" class="ui-state-default"></li>
<li id="LI2" runat="server" class="ui-state-default"></li>
<li id="LI3" runat="server" class="ui-state-default"></li>
<li id="LI4" runat="server" class="ui-state-default"></li>
<li id="LI5" runat="server" class="ui-state-default"></li>
</ul>
I tried the below code, which didn't work at all:
foreach (Control item in sortable1.Controls)
{
if (item.Controls.Contains(LI1))
{
lbTest.Text = "LI1 is in sortable 1";
}
else
{
lbTest.Text = "LI1 is not in sortable 1";
}
}
Thanks for your help