tags:

views:

37

answers:

1

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); %> 

+1  A: 
<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>
Yuriy Faktorovich
Thanks a lot. Going further, I need to display the title of a dialog box as shown above using the div title. Is there a better option?
please see the above code.
Thanks, but the title isn`t being displayed, though the dialog box is being opened.
It seems that the attribute isn`t working. I have it some other way, but the attribute to set the title isn`t working.
The title attribute of a div is only displayed when you hover your mouse over it. To get what you're looking for, place a span tag at the top of that div, and fill it in the same space I filled the title with the item.Name.
Yuriy Faktorovich
You mean I shouldn`t be using the div and instead use a span to show the dialog?
No, you can still use the div, but have a span inside it to show the name. And you set the html of the span to the name.
Yuriy Faktorovich
I have not understood. could you please give me an example. Why do I need a span when the dialog is on the div?
You're right, you don't need it. The dialog func takes the title from the title of your div. I've just tested my code and it seems to work. Do you get a javascript exception?
Yuriy Faktorovich
I don`t have an exception, rather the partial view is being displayed when the page is loaded!