Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RootFolder URL param problems - custom doc lib part

0 views
Skip to first unread message

Chris

unread,
Jan 10, 2006, 1:27:03 PM1/10/06
to
I have a custom coded web part that displays all document libraries on the
portal with the word "Procedures" in the title, and their contents. These
libraries have been set to default so that clicking on "New Document" takes
them to the "Basic Web Page".

At first, I did not include the RootFolder parameter in the URL. If the
user clicked on a link to a sub-folder, SharePoint automatically APPENDED a
URL parameter for "RootFolder". And when it does, it includes the "http://"
and portal name. Like this:

http://portal/C0/LCS/Procedures%20and%20Services/Forms/AllItems.aspx?RootFolder=http%3a%2f%2fportal%2fC0%2fLCS%2fProcedures%20and%20Services%2fGeneral%20Information

When the user clicks on "New Document", then names the basic web page, then
clicks on the "Create" button, user gets the following error (from
owssvr.dll):

"Invalid URL Parameter
The URL provided contains an invalid Command or Value. Please check the URL
again."

If I change the initial web part code to INCLUDE a "RootFolder" parameter
that is the URL Path of the listItem (which does NOT include http:// and
portal), then this error is fixed. However, the AllItems.aspx STILL appends
a "RootFolder" parameter, so now there are two of them, like this:

http://portal/C0/LCS/Procedures%20and%20Services/Forms/AllItems.aspx?RootFolder=%2FC0%2FLCS%2FProcedures%20and%20Services%2FGeneral%20Information&RootFolder=http%3a%2f%2fportal%2fC0%2fLCS%2fProcedures%20and%20Services%2fGeneral%20Information

and the folder display on AllItems.aspx now shows both the name of the
folder and the entire URL of the folder, in other words, it displays both
parameters, and to the user its a bunch of junk that doesn't need to be there.

This is really weird and I have no clue what is going on. Has anyone else
run into this?

Here's a snippet of psuedo code, just at the point at which I am creating
the URL:

string PT = listItem.ParentList.BaseTemplate.ToString();
switch(PT)
{
case "DocumentLibrary":
string rootURL = listItem["URL Path"].ToString();
whatToOutput = "<A HREF='" + rootURL + "?RootFolder=" +
SPEncode.UrlEncode(rootURL) + "'>" + listItem["FileLeafRef"] + "</A>";
break;
}
output.Write(whatToOutput);

spleenboy

unread,
Jan 18, 2006, 9:58:45 AM1/18/06
to
I have the same problem when creating a custom treeview webpart for a
document library. The url for subfolders within a library is written
out using the ServerRelativeUrl property of the SPFolder object. This
url works fine when you navigate to the folder's page, but fails when
you try to create a new document from that page with the "Invalid URL
Parameter" message.

As far as I can tell, the only difference between the url my custom
part generates and Sharepoint's url is that the custom url has the
"http://domain" path appended to the rootfolder parameter.

I've tried using the Url property of the SPFolder object, but the
result has been the same.

Has anyone else encountered this problem?

spleenboy

unread,
Jan 18, 2006, 10:20:23 AM1/18/06
to
After comparing the url created by Sharepoint and the one created by my
custom web part, I think I've solved this problem. Instead of writing
out the url of the folder using just the SPFolder.Url property, I
combined the url with the "DefaultViewUrl" property of the folder's
parent list. The final code looked like this:

string url = string.Format("{0}?RootFolder={1}",
parentList.DefaultViewUrl,
SPEncode.UrlEncode(folder.ServerRelativeUrl));

Where parentList is the SPList object that contains the the folder.

It feels like a hack, but it works.

0 new messages