when adding an item to the sharepoint list, security privileges may be required. Otherwise, it will prompt for the user name and password, on every time the page loads.
So in the following code, I am calling the function “testfunction” under security privileges
webContext = SPContext.Current.Web
SPSecurity.RunWithElevatedPrivileges(New SPSecurity.CodeToRunElevated(AddressOf TestFunction))
Then in the TestFunction, the current web can be get only by using “webContext.Site.ID”.
ie.
function TestFunction
Using site As New SPSite(webContext.Site.ID)
Dim web As SPWeb = site.OpenWeb(webContext.ID)
Dim lstColl As SPListItemCollection
——-
——
end using
end function
Tags: security privileges, sharepoint list updation, updating sharepoint list