#region DeleteBAEList ////// FUNCTION : DeleteList /// PURPOSE : To delete the list /// PARAMETERS : currentWeb -> current web /// strListName -> A string containing the list name /// RETURNS : None /// ------------------------------------------------------------------------- /// public static void DeleteList(SPWeb currentWeb, string strListName) { try { currentWeb.AllowUnsafeUpdates = true; if (IsListExists(strListName, currentWeb) == true) { SPList lst = currentWeb.Lists[strListName]; currentWeb.Lists.Delete(lst.ID); } currentWeb.AllowUnsafeUpdates = false; } catch (Exception ex) { //Error Handling Code } } #endregion
I already
covered in my previous posts about how to check whether the specified lists
exist or not? And what/why/where we can use “AllowUnsafeUpdates”.
Refer to get clear idea on it.
Refer to get clear idea on it.
- Check for the specified list exists or not also here.
- Refer to know about "AllowUnsafeUpdates"
- Error handling technique:
Happy Coding....
No comments:
Post a Comment