Frage

i'm doing a school gaming project and i am trying to create a list of players using SignalR and javascript.

this is my code

hub.client.printOutPlayerList = function (userName, userID)
    {
        $("#playerlist ul").append("<li>" + '@(Html.ActionLink(userName, "Profile", "Profile", new { id = userID }, null);)' + "</li>");
    }

this function is suppose to take in javascript variables userName and userID but the actionlink doesnt seem to recognize userName and userID

what can i do ?

War es hilfreich?

Lösung

You could do this:

hub.client.printOutPlayerList = function (userName, userID)
{
    var link = '<a href="/Profile/Profile/' + userID + '">' + userName + '</a>';
    $("#playerlist ul").append('<li>' + link + '</li>');
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top