Argh. I have this mess so far but it looks unwieldy as hell. Assistance please? 
:)
I want to take a URL of this form - /site/web[x].../myList/Forms/[anyView].aspx 
- and return:
web = /site/web[x]
listName = myList
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);

    // Set the value if this is a postback.
    if (this.Page.IsPostBack)
    {
        // Server relative URL
        string newAssetUrl = urlSelector.AssetUrl;

        // Remove listform component from URL
        string listFormPage = @"/Forms/[\/a-zA-Z0-9._%+-]+";
        Regex rgx = new Regex(listFormPage);
        newAssetUrl = rgx.Replace(newAssetUrl, "");

        // Split the remainder (site and webs)
        string [] urlArray = newAssetUrl.Split('/');

        // LastIndexOf will be list name
        string listName = urlArray[urlArray.Length - 1];

        // Loop through array -1
        for (int i = 0; i < (urlArray.Length - 1); i++)
        {
            // Add "/" to each item and concat again...??!!

        }

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Monday, 7 November 2011 1:55 PM
To: ozMOSS (ozmoss@ozmoss.com)
Subject: AssetUrlSelector - get web/list reference

Hi all,
I've added an AssetUrlSelector to an EditorPart which works great but only 
returns a server relative URL. I'd hoped the object might include useful things 
like the selected item ID and parent hierarchy.
How would I go about translating the returned AssetUrl in order to get the web 
and list instance. (The selected item will always be an image library.) I want 
to then use these as the params in my SPQuery.
I'm currently trying to split the returned URL, remove any extraneous suffix 
(AllItems.aspx), then split at the last index of / to get the Web URL and list 
name.
Is this the way to go, or is there a simpler and more reliable method?
Kind regards,

Paul

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to