Transfer value from C# to jQuery

Asked

Viewed 66 times

3

Well, I have a job in ASP.NET here where I can upload music to a folder on the computer and already have a function on C# to search the address of the archive.

Anyway, I wanted to use this path in a music player on jQuery, how come? Because it has the biggest database gambiarra here, every song has already recorded its path, so it needed a way to pull that path from C#.

Thank you from the start :)

  • Is using MVC or WebForms?

  • It helps to post the code you are using to recover bank values in C#, and remember to hide sensitive information that may affect your system’s security.

  • I am using webForms... I would even send the codes, but the gambiarra ta very big, I would need to organize a little before sending, even I’m confusing myself with what I did... The big question is whether you have a way to get a C# result and use javascript ...

  • Kuroi, you don’t need to put everything, just the essentials to help your doubt.

1 answer

1

As you have not shown the code, I don’t know exactly how you are doing, but if you want to call a function javascript through the 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 your need.

Although this solution works, it was discontinued, see more here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.