Create a web method in your Master.cs file using
[System.Web.Services.WebMethod]
attribute.
Then pass the returned value from desired Javascript function to newly created web method using AJAX call.
OR
Go through
this article to do the same using Page method and script Manager.