Show Parent Path in Search Results

Duncan Koza asked on January 31, 2020 22:58

I have developed a search page and am using <%# SearchResultUrl() %> to get the path of the page found.

Is it possible to strip away everything after and including the last / or maybe just show the path of the pages parent?

Right now, as an example, <%# SearchResultUrl() %> is giving me the following, but I only want what is bolded:

Is what I'm asking for possible?

Correct Answer

Dat Nguyen answered on January 31, 2020 23:10

This should work :

<%# SearchResultUrl().Substring(0, SearchResultUrl().LastIndexOf('/')) %>

0 votesVote for this answer Unmark Correct answer

Recent Answers

Duncan Koza answered on February 3, 2020 15:58

Thank you so much, that worked perfectly. The question I get from people all the time is. "I found the file while searching but I don't know what page it was on to get more relevant information." This will help immensely.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.