0

I get this URL "R+C%20Seetransport%20Hamburg" passing the query string using Javascript , but i need to get the URL in this format "R%2bC+Seetransport+Hamburg" using C#

Code Used:

        var listname = $(this).text();
        var listname1 = listname.trim();

        // var senderElement = e.target;
        var afullUrl = '<%=SPContext.Current.Web.Url%>';
        var aurl = afullUrl + "/_Layouts/15/RUM/View_Details.aspx?List_Name="+listname1;

        window.location = aurl;
3
  • I would reword this question. Start by listing the actual input filename you're starting with. Then list the expected output followed by the actual output and your code. Take C# out of the picture because you're really trying to do this in javascript I think. Or if you want to make this a C# question start with "Here's what I'm receiving in C#, how can I make it look like this?" and show the code you've used to try and convert it. Commented Jun 29, 2017 at 5:22
  • I think you just need to decode server side Commented Jun 29, 2017 at 5:25
  • when i decode the query string using this code HttpUtility.UrlDecode(Request.QueryString["List_Name"].ToString()); i get like this "R C Seetransport Hamburg" but i need "R+C Seetransport Hamburg" like this. If i Encode the same code "R+C+Seetransport+ Hamburg" i get in this format Commented Jun 29, 2017 at 5:37

1 Answer 1

1

If you are looking for %20 to be replaced by + sign then you can do the following:

var listname1 = listname1.replace(/%20/g, "+");

The %20 represents a white space. And %2b represents +(plus sign).

The problem seems to lie in the Urldecoding. You can also try decodeURIComponent() for removing %20 back to whitespace.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.