With the MVC3 Razor synax, one may render a string like so
@ViewData("photo")
My problem is: How can I append a dot to the above code. The following will result in a "Public member 'jpg' on type 'String' not found.":
@ViewData("photo").jpg
I've tried the following code but does not produce my intended result:
@ViewData("photo") .jpg @ViewData("photo"):.jpg @ViewData("photo") & ".jpg"
Thanx for advance for your help. And please dont advice me to append the "jpg" in the controller's code like so:
ViewData("photo") = "filename.jpg"
I've searched the Net for the same problem but found none, not even something
similar. By the way, I'm using VB.net.
How about this?
@(ViewData("photo")).jpg
Edit: And with the dynamic ViewBag:
@(ViewBag.photo).jpg
Adding as answer:
@(ViewData("photo") + ".jpg")
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