I think I just need someone to show me the obvious.
I have a spark partial
_MessageItem.spark
that is used within a view
like so
<for each="var m in messageList">
<MessageItem message="m"/>
</for>
the partial looks like this:
<tr id="${message.MessageId}">
<td >${message.CreateDate.ToString("M/d/yy h:mm")}</td>
<td >
<b>${message.Subject}</b>
</td>
<td >${message.FromUser.FullName}</td>
<td >${message.ToUser.FullName}</td>
</tr>
<tr>
<td/>
<td colspan="3">${message.Body}</td>
</tr>
works like a champ, except when I try and call the partial directly from an action like so:
public ActionResult GetMessage(Message message)
{
return PartialView("MessageItem",message);
}
When I do the above I get
error CS0103: The name 'message' does not exist in the current context
So my current solution is to create a wrapper partial that feeds the MessageItem partial
like so: _ActionMessageItem.spark:
<MessageItem message="(Message)ViewData.Model"/>
So can someone state the obvious and tell me how to modify
1) Modify my MessageItem partial so whether being called from PartialView() or within a .spark file it will work
2) Tell me how I need to modify my Controller Action so it won't throw an exception