I am adding a list item in from an application page which is redirected from web part page.
My code is :
protected void Page_Load(object sender, EventArgs e)
{
SPSite site = new SPSite("http://bipc11:1234/sites/webparts");
SPWeb web = site.RootWeb;
web.AllowUnsafeUpdates = true;
SPUser currentUser = web.CurrentUser;
SPList list = web.Lists["Cart"];
SPListItem item = list.AddItem();
item["Picture"] = Request.QueryString["title"];
Response.Write("<script> alert('Pictrue Updated')</script>");
item["User"] = currentUser;
Response.Write("<script> alert('User Updated')</script>");
item.Update();
Response.Write("<script> alert('Item Updated')</script>");
web.Update();
web.AllowUnsafeUpdates = false;
Response.Write("<script> alert('Value Added To Cart Successfully')</script>");
Response.Redirect(Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(web.Url, "/SiteAssets/WebPartPage.aspx"));
}
Here field Picture
is of type look up in Cart
list. User
is the type of person or group. Java script to redirect to the application page is:
function myfunction(title)
{
window.location.assign("http://bipc11:1234/sites/webparts/_layouts/AddValueToCartList/AddValueToCartList.aspx?title="+title);
}
When the page is redirected to the application page I am getting above mentioned error.
What am I missing? Please help.