Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Ok, I am new to server side development (especially SP development) and I don't know if this is possible but here goes:

I have a custom list which I populate from a local folder on my file system. The folder has many nested folders and files of different formats.

I added a custom ECB menu item for this particular list and I want to be able to open the file (either in the browser or the specific application) when the menu item in the ECB menu for a list item is clicked.

Here's what I have for e.g.:

SPUserCustomAction action = list.UserCustomActions.Add();
action.Url = "file:///C://Users//Administrator//Desktop//Dir//file1.txt";
//...

But when I click the custom menu item in ECB, I get a browser alert saying: Invalid Page URL.

Am I missing something or is there a particular way of opening files by any other method that can help my issue?

share|improve this question
    
it gives the same browser alert even after using my server name i.e. file://servername/full_path but in vain –  kd22 Mar 18 at 14:36

1 Answer 1

This should be

action.Url = "file:///C:/Users/Administrator/Desktop/Dir/file1.txt";

Triple slash after the file:, then single slashes (not double) instead of the filesystem backslashes.

share|improve this answer
    
Yes, but still no luck :( –  kd22 Mar 18 at 15:15
    
Have you tried to paste the link in the address bar of your browser? –  Hinek Mar 19 at 11:55
    
yes, it works fine when copied directly in the browser –  kd22 Mar 19 at 19:56
    
have you checked (with a brwoser developer tool F12 or source view), what link is finally rendered in the HTML page and if it differs from the Link you want? –  Hinek Mar 20 at 15:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.