I have a table of roles that has checkboxes with access or not. I need a help-button on the right most column that shows information for the role using JQuery Dialog. For some reason the dialog only shows every second time.
Below is the code I use:
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<%foreach (Role role in ViewData["Roles"] as List<Role>)
{ %>
<tr>
<td width="20%">
<%=role.RoleName %>
</td>
<td width="70%">
<%=Html.CheckBox(role.RoleName, Model.IsInRole(role.LoweredRoleName)) %>
</td>
<td width="10%">
<%if (!string.IsNullOrEmpty(role.Description))
{ %>
<%Html.RenderPartial("Help", new KeyValuePair<string, string>(role.RoleName, role.Description)); %>
<%} %>
</td>
</tr>
<%} %>
</table>
Help.aspx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<KeyValuePair<string, string>>" %>
<a href="#" onclick="$('#<%=Model.Key.Replace(" ", "") %>').dialog(); return false;">
<img border="0" src="../../Content/Images/help_icon.gif" alt="?"/>
</a>
<div id="<%=Model.Key.Replace(" ", "") %>" title="<%=Model.Key %>" style="display:none;">
<%=Model.Value %>
</div>