Last post Aug 24, 2017 04:33 AM by JBetancourt
Member
3 Points
10 Posts
Aug 23, 2017 07:49 PM|peruchox|LINK
I'm trying to display a user photo on a page using the img html element from a model.
@page @model WebCrewLog.Pages.Entries.IndexModel @{ } <h2></h2> <div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-lg-2"> <img class="img-circle" src="@Url.Content(Model.TeamMember.PhotoID)" style="width: 80%; height: 80%" /> </div> <div class="col-lg-5"> <p> <label class="text-success">@Html.DisplayFor(model => model.TeamMember.FirstName) @Html.DisplayFor(model => model.TeamMember.LastName)</label><br /> Hired Date:<label class="text-success">@Html.DisplayFor(model => model.TeamMember.HireDate)</label><br /> </p> </div> <div class="col-lge-5"> <p> Position:<label class="text-success">@Html.DisplayFor(model => model.TeamMember.Position.Name)</label><br /> Shift: <label class="text-success">@Html.DisplayFor(model => model.TeamMember.Shift.Name)</label> </p> </div> </div> <div class="row"> </div> </div> </div>
The problem is that I'm getting this error.
_TeamMember.cshtm
so is not finding it but why? I tried inserting a lambda express (model => model.TeamMember.PhotoID) but i'm getting another error.
I know that that field works because if I use a displayfor element I can see the value. But is the @Url.Content that I'm having an issue with.
any ideas?
thank you
Participant
1380 Points
608 Posts
Aug 24, 2017 04:33 AM|JBetancourt|LINK
and how does Model.TeamMember.PhotoID looks like? does it looks like: "~/path/file.jpg" ?
Member
3 Points
10 Posts
Trying to display an image from model but I'm getting NullReferenceException
Aug 23, 2017 07:49 PM|peruchox|LINK
I'm trying to display a user photo on a page using the img html element from a model.
The problem is that I'm getting this error.
WebCrewLog.Pages._TeamMember_Page+<ExecuteAsync>d__0.MoveNext() in
_TeamMember.cshtm
<img class="img-circle" src="@Url.Content(Model.TeamMember.PhotoID)" style="width: 80%; height: 80%" />
so is not finding it but why? I tried inserting a lambda express (model => model.TeamMember.PhotoID) but i'm getting another error.
I know that that field works because if I use a displayfor element I can see the value. But is the @Url.Content that I'm having an issue with.
any ideas?
thank you
Participant
1380 Points
608 Posts
Re: Trying to display an image from model but I'm getting NullReferenceException
Aug 24, 2017 04:33 AM|JBetancourt|LINK
and how does Model.TeamMember.PhotoID looks like? does it looks like: "~/path/file.jpg" ?
Please remember to click "Mark as Answer" the responsES that resolved your issue.