Messages In This Digest (1 Message)
- 1.
- C# - custom web part to post "Link To A Document" content type From: rjohnandmore
Message
- 1.
-
C# - custom web part to post "Link To A Document" content type
Posted by: "rjohnandmore" rjohnandmore@yahoo.com rjohnandmore
Wed May 2, 2012 10:50 am (PDT)
Hello! I have a C# custom web part that unloads documents > 5Meg to an Sahre Drive. This web part creates a :Link to a Document" content type entry in the document library.
As usual, the web part works PERFECT on MY development machine :0) However, as soon as we load it to TEST it errors out when it attempts to update the -- item["URL] = myShareURL
I am also using SPSecurity.RunWithElevatedPrivilege s(delegate( ) and have verified that I am using "System Account"
That error usually occurs when the "Link to a Document" Content Type has not been enabled for that Library; but it has been. I CAN create an entry using that Content Type via the browser in the library.
Been stumped for 2 days now. Have even tried it on 2 different servers with the SAME result: No Go.
Any ideas???? I cant see how it is the code -- but here is the specific section:
//Create SPFile object
SPFile uploadFile = null;
uploadFile = myLibrary.Files.Add(oWeb. Site.Url + "/" + urlOfFile, new MemoryStream( new UTF8Encoding( ).GetBytes( redirectPageHTML .ToString( ))), true);
// Create SPField onject
SPListItem item = uploadFile.Item;
//Update Content Type
fieldName = "Content Type";
fieldValue = "Link to a Document";
item["Content Type"] = fieldValue;
//Update File Share URL
fieldName = "URL";
fieldValue = myShareURL
item["URL"] = fieldValue;
//Commit changes
item.Update();
Need to Reply?
Click one of the "Reply" links to respond to a specific message in the Daily Digest.
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Individual | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
No comments:
Post a Comment