0

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??

1 Answer 1

1

A javascript string needs to be quoted:

<script>
var itemApiUrl = '@ExtensionMethods.ItemApiURL().ToString()';
</script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.