Click here to Skip to main content
15,886,058 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var result = "Url.Content(~\\Content\\Documents\\"+data+")";


I want to append the '@' sign to result

output should be

var output= "@Url.Content(~\\Content\\Documents\\"+data+")";



I am using javascript function

 function PlayVideo(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var tData = dataItem.POnePagerId;
           var GetVideoLinkLink = "@Url.Action("PlayVideo", "ProviderOnePager")";
                $.ajax({
                    url: GetVideoLinkLink,
                    type: "GET",
                    dataType: 'html',
                    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                    data: {
                        'POnePagerId': tData
                    },
                    success: function (data) {
                         video.center().open();
                        debugger;
                        
                        var result = "Url.Content(~\\Content\\Documents\\"+data+")";
                       
                        var mediaPlayer = $("#mediaPlayer").data("kendoMediaPlayer");
  // check the currently loaded media
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(mediaPlayer.media());
  // change the media loaded in the widget
  mediaPlayer.media({
                title: "Responsive Website Delivers for Reeves Import Motorcars",
                source: [ { url: result }, { quality: "720p", url: result } ]
            });

              
                    }
                });
    }


in the ajax success I want to pass the video location to kendoMediaPlayer as source the video location is
\\Content\\Documents
and the video name test.mp4
the
kendoMediaPlayer 
accepts source only like
@Url.Content(~\\Content\\Documents\\test.mp4


What I have tried:

i have tried but in js file @ sign throwing error
Posted
Updated 14-Oct-21 0:37am
v2
Comments
Richard MacCutchan 14-Oct-21 5:27am    
I just tried something similar and it works fine. Please use the Improve question link above, and add the actual code, show the contents of data, and the actual result that you see.
murkalkiran 14-Oct-21 5:50am    
data = "test.mp4"

i want build a URL like ~\\Content\\Documents\\test.mp4

but this Url should be inside "@Url.Content("~\\Content\\Documents\\test.mp4")
Richard MacCutchan 14-Oct-21 5:53am    
Sorry, that is still not clear. Please do what I asked and update your question with the full details of your code, and what results you receive.

1 solution

The Url.Content helper method[^] runs on the server. You cannot pass Javascript variables to it.

You may be able to use:
JavaScript
const baseUrl = "@Url.Content("~/Content/Documents/")";
const result = baseUrl + data;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900