I have some logic in C#, that controls which image I should show on a webpage.
basically I want to update the image, when a button is pushed, but I want to do it in the controller of a razor page. And not I javascript or html, where it is fairly simple.
I am thinking somehow along the lines of: // the controller
public class APageController {
...
public IActionResult AButtonPushed() {
bool yes;
...
// some logic that changes yes
...
aPageModel.ImagePath = yes // how do I access the
? "\images\true.jpg" // razor view class from
: "\images\ohNooo.jpg" // controller
return RedirectToPage("/aPage");
}
...
}
// the razor page model
public class aPageModel : PageModel {
...
public string ImagePath {get;set;}
...
}
// and the razor page html
...
< img src="@Model.ImagePath"/>
...
or it maybe I should use some helper tag, to force the page to react to the change of imagePath in the PageModel.