문제

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 ?

도움이 되었습니까?

해결책

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>');
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top