Geeks With Blogs
My Blog

Here is an example of a case in which I wanted to overload a Spark macro to display two input elements in one table row.

<table>
   !{Row(x => x.Name)}
   !{Row(x => x.Description)}
   !{Row(x => x.Price)}
   !{Row(x => x.SaleStartDate, x => x.SaleEndDate)}
   !{Row(x => x.SaleDiscount)}

   <tr>
          <td></td>
           <td>!{Html.SubmitButton("Save")}</td>
    </tr>
</table>

<macro name="Row" expression="Expression[[Func[[ProductViewModel, object]]]]">
    !{Row(expression, null)}
</macro>

<macro name="Row" expression="Expression[[Func[[ProductViewModel, object]]]]" expression2="Expression[[Func[[ProductViewModel, object]]]]">
    <tr>
           <td>!{Html.LabelFor(expression)}</td>
           <td>!{Html.InputFor(expression)} 
                   <if condition="expression2 != null">
                           !{Html.InputFor(expression2)}
                   </if>
           </td>
    </tr>
</macro>
Posted on Saturday, February 13, 2010 11:11 AM | Back to top


Comments on this post: Overloading Spark Macros

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Ryan Ohs | Powered by: GeeksWithBlogs.net