learning
learning

Reputation: 11725

How to set title to a div in mvc?

I have the following code, but it`s giving me errors

 <div id="ChangePassword" title="Change password for "&<%=item.Name%>>
        <%Html.RenderPartial("PasswordDetails", Model); %>
    </div>

I need to display the name in the title. How can I do that?


I actually want to dipslay the name of the employee in the div when the link is clicked. How can I do that?

<% foreach (var item in Model.employee) { %>

    <tr>
        <td><%=item.Name %></td>
        <td><%= Html.ActionLink("Edit", "Edit", new { userID = item.ID })%></td>
        <td><a href="#" id="password_link" >Change Password</a></td>
        <td> <%= Html.ActionLink("Delete", "Delete", new { id = item.ID }, new { Class = "deleteLink", title = item.Name })%></td>           
   </tr>

<% } %>

  $("#password_link").click(function() {
        $('#ChangePassword').dialog('open');
        return false;

        });


<div id="ChangePassword" title="Change password for <%=item.Name%>"> 
<%Html.RenderPartial("PasswordDetails", Model); %> 

Upvotes: 0

Views: 1196

Answers (1)

Yuriy Faktorovich
Yuriy Faktorovich

Reputation: 68687

<div id="ChangePassword" title="Change password for <%=item.Name%>">
    <%Html.RenderPartial("PasswordDetails", Model); %>
</div>

You didn't have the actual name in the title tag, your quotes ended too early.


To display the name in the div, I'd do the following:

<a href="#" onclick="$('#ChangePassword').attr('title', '<%= item.Name %>');
    $('#ChangePassword').dialog('open');return false;" 
    id="password_link" >Change Password</a>

Upvotes: 1

Related Questions