4
Error   5   ; expected  

<link rel="Stylesheet" type="text/css" href="<% ***ResolveUrl("~/Css/test.css");***  %>"/>

Do i need to give ; over here as my solution is not still working it starts giving some other error

2
  • What did you paste the title from that had smart quotes? Commented Dec 9, 2009 at 16:09
  • 2
    Learn the language. Don't ask questions whenever you get stuck because you don't know what you're doing. Commented Dec 9, 2009 at 16:12

1 Answer 1

15

You need to add an equals sign, like this:

<link rel="Stylesheet" type="text/css" href="<%= ResolveUrl("~/Css/test.css") %>"/>

Explanation:

<% %> blocks insert entire statements or blocks into the generated function. If you want to declare a variable, start a loop, or run a stand-alone statement, use a <% %> block. The code in the block must be a complete statement; it gets inserted in the middle of the method.

<%= %> blocks evaluate an expression and print the result; use them when you want to call a method or read a variable and output the result. The code in the block must be an expression; it turn into an argument for a method call.

Sign up to request clarification or add additional context in comments.

1 Comment

You only add a ; to a complete, standalone, statement. Expressions are not statements and cannot have semicolons. Since you want to print the return value of the method, you want to use an expression, so you should add an = and not a ;.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.