views:

159

answers:

1

Can I use a spark variable inside an html helper?

Say we have

<var url="Url.Action(“get”)" />    
!{Html.Image("~/Content/up.png")}

Now if I need to use the url inside Html.Image as an attribute(part of the 2nd param) to get

<img src="~/Content/up.png" type="~/engine/get" />

how do I go about doing it?

+3  A: 
<var url='Url.Action("get")' />

is converted to

var url = Url.Action("get");

when interpreting view code, so you can use url as C# variable later:

!{Html.Image("~/Content/up.png",url)}
LukLed