There is an error when trying to include the javascript variable "selectedValue" in the c# function being called. SelectedValue has red underline error inside the GetTotalLicensesCount.
function drawExpireGauge() {
var selectedValue = "30days";
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Expiring', <%=GetTotalLicensesCount(null, null, null, selectedValue, selectedValue, null, null)%>],
['New', <%=GetTotalLicensesCount(null, null, null, null, null, null, selectedValue)%>],
['Not Used', 0]
]);
}
if "30days" is simply placed inside the GetTotalLicensesCount function instead of the variable, it works.
I did due-diligence and searched around the forum for a similar question but couldn't find any, please let me know how the question should be changed or if there is a reasonable duplicate that answers the question.
var selectedValue = "30days";is being executed as javascript (in the users browser) not in Razor (on the server before being sent to the user). Wrap it in@{and}to have it evaluated on the server. However, if30daysis going to be taken from input from the page (for example whatever a user clicks/types in), you'll need to send a request to the server to properly evaluate it as Keith mentions