tags:

views:

28

answers:

3

I have

 <%var test = ViewData["test"];%>

 <ul class= "list" id = "<%test;%>">

but having error message:

Only assignment, call, increment, decrement, and new object expressions can be used as a statement

What is wrong?

+3  A: 

Your output block needs to use <%= %> or <%: %> if you want it encoded, like this:

<ul class="list" id="<%=test%>">

Though, unless you need the variable all over the place, just use <%= %> on the original ViewData["test"], it's a bit cleaner, at least to me.

Nick Craver
+1  A: 

try this...

<ul class= "list" id = "<%=test%>"> 

...you were missing the '=' symbol before 'test' & added an extra ';' after it.

belugabob
+2  A: 
 <ul class= "list" id = "<%=ViewData["test"]%>">
Alex Reitbort