Dinesh Kumar
Dinesh Kumar

Reputation: 13

Issue on URL using Javascript

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;

Upvotes: 0

Views: 50

Answers (1)

raks
raks

Reputation: 329

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.

Upvotes: 1

Related Questions