开发者

ASP.NET MVC3 Razor @string dot problem

开发者 https://www.devze.com 2023-02-26 05:22 出处:网络
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.

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 y开发者_开发问答our 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")


You could always try:

@string.concat(ViewData("photo"),".jpg")

0

精彩评论

暂无评论...
验证码 换一张
取 消