Reputation: 77
I am trying to put string value to my view page it's something like this
public static class ExtensionMethods
{
public static string ItemApiURL()
{
return WebConfigurationManager.AppSettings["ItemApiLocation"];
}
}
this will read my web config value and return the value to my view page java script
<script>
var itemApiUrl = @ExtensionMethods.ItemApiURL().ToString();
</script>
but I am getting in runtime like this var itemApiUrl = http://example.com:22273/odata/ItemQC?
as it is no quotation " " this give me error for me Any thought??
Upvotes: 0
Views: 59
Reputation: 187
A javascript string needs to be quoted:
<script>
var itemApiUrl = '@ExtensionMethods.ItemApiURL().ToString()';
</script>
Upvotes: 1