0

Below is my code in HTML

<% for (int i = 2; i < 8; i++)
         {%>
            hello  <%  i.ToString();%>
<%   } %>

What i expect outupt is

hello2 hello3 hello4 hello5 hello6 hello7

But it does not append i values, it simply printing the hello 6 times This is just a overview of a concept that i want to implement, i have many other alternates to do the same, but just I wanna know what i am doing wrong, because i think this can be done

Please advise Thanks

4
  • If the answer meets your request, Its better to mark as answered. Commented Jan 21, 2015 at 5:33
  • your answer throwing compile error Commented Jan 21, 2015 at 5:59
  • @RahulSingh, your answers does not suits to my need, As i have mentioned in post, I have many alternates, and your answer is one of them, Commented Jan 21, 2015 at 6:37
  • @Md.ParvezAlam You as you know 'i' got value correctly, you wanna just see that on document ? Commented Jan 21, 2015 at 6:45

1 Answer 1

2

Small Syntax correction <% i.ToString();%> to <%= i.ToString();%>

<% for (int i = 2; i < 8; i++)
{%>
    hello  <%=  i.ToString();%>
Sign up to request clarification or add additional context in comments.

2 Comments

@kiran, u forgot the closing brace. It should with <%= i.ToString); } %>
@RichardSchneider I ignored that missing,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.