Executing a method from markup

I am trying to set some javascript data (json) in my markup by calling a method in my codebehind file. The markup is as follows:

Line 12: var businessTypes = "<%=GetBusinessTypes(); %>";

The method is executed and it returns a string value, but then this exception is thrown

CS1026 :) expected

repainting the line 12 shown above.

+3
source share
1 answer

I believe because you included the semicolon after calling the method. The source tags "<% =%>" essentially complete your code withResponse.Write(...);

Try:

var businessTypes = "<%= GetBusinessTypes() %>";
+3
source

Source: https://habr.com/ru/post/1712116/


All Articles