0

I try to set the CSS class of each row dynamically for a HTML table, I found a blog with info how to do it but it doesn't seem to work for me.

    <% foreach (var item in Model){%>
    <tr class= "<% Model.GetRowClass(item, "alt", "reg");%>">

Model.GetRowClass returns a string with the style name, when I run it however no style is applied.

2
  • what class is being applied, and what does your stylesheet look like? The problem is not necessarily in your ASP. Commented Jan 3, 2012 at 19:32
  • what does the html for the <tr> look like after the page has rendered? Commented Jan 3, 2012 at 19:33

1 Answer 1

2

You need to use <%= %> instead of <% %>. Try this:

<% foreach (var item in Model){%>
<tr class='<%= Model.GetRowClass(item, "alt", "reg") %>'>
<% } %>
Sign up to request clarification or add additional context in comments.

Comments

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.