<%@ Import Namespace="System.Data.OracleClient" %>
<%@ Import Namespace="Microsoft.SharePoint.Client" %>
<%@ Import Namespace="System.Net" %>
<script runat="server">
protected void btnDelete_Click(object sender, EventArgs e)
{
try
{
ClientContext context = new ClientContext("http://ServerName/sites/test/");
using (context)
{
NetworkCredential credential = new NetworkCredential("Admin", "$Password$", "ServerName");
context.AuthenticationMode = ClientAuthenticationMode.Default;
context.Credentials = credential;
List list = context.Web.Lists.GetByTitle("City");
Microsoft.SharePoint.Client.ListItem item = list.GetItemById(Convert.ToInt32(txtID.Text));
item.DeleteObject();
context.ExecuteQuery();
Response.Write("Item Deleted Successfully.");
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
</script>