0

I really like the bindings feature of spark, it really improves markup but I have come across a small problem. Is it possible to create a spark binding that doesn't have any code in it just html? For example:

    <element name="searchbox">
        <div class="searchbox">
            <input type="text"/>
            <img src="/content/images/cross.png" placeholder="${sharedres.searchplacheolder}"/>
        </div>
    </element>

When I try and render the element searchbox above I get a page render error:

error CS1501: No overload for method 'Write' takes 0 arguments

Is there a way to do this or do can you only provide code in a binding?

jcvandan
  • 14,124
  • 18
  • 66
  • 103

1 Answers1

3

You can do it, the whole binding just needs to represent a string like so turn your code into a string and escape all the angle brackets and it should work:

        "&lt;element name=\"searchbox\"&gt;&lt;div class=\"searchbox\"&gt;&lt;input type=\"text\"/&gt;&lt;img src=\"/content/images/cross.png\" placeholder=\"@placeholder\"/&gt;&lt;/div&gt;&lt;/element&gt;"

having said that, you might be better off placing something like this in a partial view.

lomaxx
  • 113,627
  • 57
  • 144
  • 179
  • thx for the answer, and I second that it should be in a partial I suppose, that is probably what I will do! – jcvandan May 31 '12 at 10:04