Tips to debug Razor (or any server-side code rendering markup) more effectively:
- View the rendered HTML! is it correct?
- Remove styles/scripts until you are sure the server is rendering the values you want.
- Add a breakpoint to your controller to make sure you are passing data to the view. Your rendering logic may be fine.
That said, your code appears to work fine. I dummied up some data:
@{ var t = new { Id = 1234, tTags = new List<string> { "foo", "bar", "baz" } }; }
<b><a href="#" onmouseover="tooltip.pop(this, '#tagsdiv@(t.Id)')">tagged</a></b>
<div style="display: none;">
<div id="tagsdiv@(t.Id)">
<span class="menu">
@for( int i = 0; i < t.tTags.Count; i++ ) {
<b>@Html.ActionLink( t.tTags[i], "TagDetail", "Forums", new { tag = t.tTags[i], page = 0 }, null )</b>
}
</span>
</div>
</div>
This yields:
<b><a href="#" onmouseover="tooltip.pop(this, '#tagsdiv1234')">tagged</a></b>
<div style="display:none;">
<div id="tagsdiv1234">
<span class="menu">
<b><a href="">foo</a></b>
<b><a href="">bar</a></b>
<b><a href="">baz</a></b>
</span>
</div>
</div>
One thing that really looks wrong here is '#tagsdiv1234'
. Are you sure your tooltip needs an ID including the CSS/jQuery ID selector ("#")?
Another thing that stands out is your tooltip container is wrapped with an outer div
set to display:none
. The ID'd element will always be hidden because its parent is hidden, even if the tooltip code tries to show it.
Another possibility is that your ID contains a character illegal in an element identifier.