Transfer value from C# to jQuery


Well, I have a job in ASP.NET here where I can upload music to a folder on my computer and I already have a C# function to get the file address right.

Anyway, I wanted to use this path in a jQuery music player, how? Because it has the biggest database workaround here, each song has its path registered, so I needed a way to pull that path from C#.

Thanks in advance 🙂


Since you didn't show the code, I don't know exactly how you're doing it, but if you want to call a javascript function via CodeBehind can be done like this:

var caminhoMusica = /* seja lá como você pega */
Page.RegisterClientScriptBlock("SeuScript","<SCRIPT Language='javascript'> alert(" + caminhoMusica + "); </SCRIPT>");

I used alert because it is an example only, adapt as needed.

Although this solution works, it has been discontinued , see more here .

Scroll to Top