Ramon Ortega

Ramon Ortega

  • NA
  • 37
  • 2.5k

How to display user picture base on the username in ASP MVC?

Jan 31 2022 11:38 PM

Hi guys i have this problem how can I display the picture of the user base on the username when the pictures is in the Network Folder \\10.10.25\\AquariusImages\IdPictures\rortega.jpg 

This is the js function

//DTR functions
DTR.init = function () {
    user = $("#user").text();
    username = $("#username").text();
    userIdEmployee = $("#userIdEmployee").text();

   if  ($('#userGender').text() == "Female") {
        $("#imageProfileFemale").show();
        $("#imageProfileMale").hide();
   } 
       else {
        $("#imageProfileMale").show();
        $("#imageProfileFemale").hide();
    }

    $("#dtrBTN").addClass("active");
    $("#eventManagerBTN").removeClass("active");
    $("#hrisBTN").removeClass("active");

    DTR.SetUserData(); 
    DTR.SetDate();
    DTR.GetTransactionLogs();
}

DTR.SetUserData = function () {
    $.ajax({
        url: "/Modules/FetchUserData",
        type: "GET",
        data: {
            username: username
        },
        dataType: "json",
        success: function (data) {
            for (var i in data) {
                $('#iDNumber').val(data[i].employeeIdNo);
                $('#employeeName').val(data[i].employeeName);
                $('#employeePosition').val(data[i].positionName);
                $('#employeeDepartment').val(data[i].departmentName);
                $('#timeIN').val(data[i].inTimeTransLog);
                $('#timeOUT').val(data[i].outTimeTransLog);
            }
        }
    });
}
 

This part is for the Header.cshtml where the user picture thumbnail is located

 <div class="col-md-4">
                <div class="pr-5 text-white" style="font-size:14px;font-weight:bolder">
                    <span id="imageProfileMale" style="display: none;">
                        <img src="~/image/default_male.png" style="width:40px" />
                    </span>
                    <span id="imageProfileFemale" style="display: none;">
                        <img src="~/image/default_female.png" style="width:40px" />
                    </span>
                    <span id="imageProfileRortega" style="display: none;">
                        <img src="~/image/rortega.jpg" style="width:40px" />
                    </span>
                    <span id="userGender" hidden>@ViewBag.UserGender</span>
                    <span id="userIsApprover" hidden>@ViewBag.IsApprover</span>
                    <span id="user" style="text-transform: capitalize;">@ViewBag.User</span>
                    <span id="username" style="text-transform: capitalize;" hidden>@ViewBag.Username</span>
                    <span id="userIdEmployee" hidden>@ViewBag.IDEmployee</span>
                </div>
            </div>
        </div>

 

how can I display the user picture guys? please help


Answers (1)