Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

mvc razor - update html img src from c#

I'm new to mvc and razor

i have an image showing on first load with no issues (camera1.jpg)

its written in the c# backend and set on the screen with no problem at all (on initial load)

then, when the c# tries to set a different image (camera3.jpg), it doesn't change from image1 to image2
however when i debug its showing the new image  (camera3.jpg) in the variable, but the one on screen is always showing the original (camera1.jpg)

here is the code,and it show the variable with the new image, but it does not update the img
User generated image
what am i doing wrong?
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Hi,

You need to wrap @Url.... with double quotes.

<img src="@Url.Content(_url)".....>

Open in new window


Giannis
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.