开发者

Images in MvcContrib Grid

开发者 https://www.devze.com 2022-12-31 21:12 出处:网络
Topic question: If i already have helper which returns me image according with parameter (true or false)

Topic question:

If i already have helper which returns me image according with parameter (true or false) I called it like this

and it is returns me <img src=... />

I was thinking to use MvcContrib but i cant use <%= %> syntax in embedded blocks

Then i find out that it is possible to do like this:

p => "img tag src=/images/Available.png/>").Named.(“A”).DoNotEncode();

But i want to put conditions, somth that like that:

if(item.Availible)
     column.For(p => "img tag src=/images/Available.gif").Named   (“A”).DoNotEncode();
else
     column.For(p => "img tag=/images/Notavailable.gif").Named(“A”).DoNotEncode();

i was tried to make it like this:

column.For(p => ((item.Avail开发者_StackOverflow中文版ible==false) ? "img tag src=/images/Notavailable.png" : "img tag=/images/Availible.png").Named(“A”).DoNotEncode();

but it is doesn't working properly.

is there any way of doing this?


I think this is what you're looking for:

column.For(p => p.Available(true) ? "<img src=\"/images/Available.gif\">" : "<img src=\"/images/Notavailable.gif\">").Named("A").DoNotEncode();
0

精彩评论

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