I've got an exception throwing at this line, and can't figure out why...maybe someone else can spot it
<img src="@{Model.Image != null ? Model.Image.FileName : "";}" width="200px" id="ImagePreview"/>
The exception I'm getting is:
error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
The If Condition The if statement returns true or false, based on your test: The if statement starts a code block. The condition is written inside parenthesis. The code inside the braces is executed if the test is true.
Razor is a simple programming syntax for embedding server code in web pages. Razor syntax is based on the ASP.NET framework, the part of the Microsoft.NET Framework that's specifically designed for creating web applications.
You need to use the expression (
explicit)
code block style for that expression:
<img src="@(Model.Image != null ? Model.Image.FileName : "")" width="200px" id="ImagePreview"/>
see the gu's post
Try wrapping it in parenthesis instead of curly brackets:
<img src="@(Model.Image != null ? Model.Image.FileName : "")" width="200px" id="ImagePreview"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With