This topic demonstrates how to clear items from the C1NavigationList control using client-side script. This topic assumes that you have created an AJAX-enabled ASP.NET project that contains a ScriptManager control (see Creating an AJAX-Enabled ASP.NET Project) and a C1NavigationList control.
Complete the following steps:
1. Add a C1NavigationList control to your project.
2. Add at least one item to the C1NavigationList control (see Adding Navigation List Items to the C1NavigationList Control).
3. Click the Source tab to enter Source view.
4. Enter the following JavaScript after the <form> tag:
<script language="javascript" type="text/javascript">
//Find the navigation list client-side ID
function getNavList() {
return Sys.Application.findComponent("<%=C1NavigationList1.ClientID%>");
}
//Get the navigation list items and then call a function to clear them
function clearItems(){
var navList = getNavList();
navList.get_items().clear();
}
</script>
5. Add the following markup beneath the </div> tag to add a button to the page:
<input id="ClearButton" type="button" value="Clear Items" onclick="clearItems()"/>
6. Save the project and open it in a Studio for iPhone-compatible browser. Click the Clear button and observe that the list items are cleared from your page without postback.