Hello,
I have a signalr bound grid. The grid has custom popup editor with Tabstrip. First tab - upload picture, or show picture based on ImageUrl field of currently edited record.
So, I'm trying to access:
- @Model.ImageUrl - it throws null exception and breaks the page overall, or
- @Html.ValueFor(model=>model.ImageUrl) - it is always null, but I'm sure there are values in database
I have tried the same, just to test it, with for example Firstname field from the same model - the same result
@Html.LabelFor(model=>model.ImageUrl) and @Html.EditorFor(model=>model.ImageUrl) work fine, I can see the label and the correct value inside a textbox.
<div class="row">
<div>
@Html.ValueFor(model => model.Firstname) @*this is always null, but I need a value*@
</div>
<div>
@* @Model.Firstname this breaks whole page with null exception*@
</div>
<div>
@Html.EditorFor(model => model.Firstname) @*this works correctly*@
</div>
</div>
/////////// below is the code, why I need the value
<div id="pictures" class="picture dropZoneElement">
@if (Html.ValueFor(model => model.ImageUrl) != null)
{
<div class="k-edit-label">
<img src="Files/Images/" + @Html.ValueFor(model => model.ImageUrl) />
</div>
}
else
{
<div class="textWrapper">
<p><span>+</span>Add Image</p>
<p class="dropImageHereText">Drop image here to upload</p>
</div>
}
</div>
Kind regards
DC