I've inherited some code... and am trying to convert it to use MVC 3, with Razor, the VBHTML is as follows:
For Each Message As MessageDetailsModel In Model.Messages
@<div id='@Message.HeaderId' class='@Message.HeaderCss' onclick=@(String.Format("shMsgTree('{0}','{1}',{2},'{3}');", Message.HeaderCss, Message.HeaderId, Message.MessageId, Message.UserId))>
... more stuff...
</div>
Next
Stepping through the code, the String.format resolves to this:
shMsgTree('sh_msg_GridItem sh_msg_MessageRead ','divHeader0',40,'{85A433F0-4054-42E7-B778-3EF005E411D3}');
which is what I want on the page, but for some reason, it gets output on the page as this:
shMsgTree('sh_msg_GridAltItem" sh_msg_MessageRead="
The properties on the model are all strings.
Am at a bit of a loss as to how to get it to render. Originally the entire onclick javascript was being returned in the Model, but that didn't render any better either.
Any suggestions would really be welcome. Thanks!
<p>? Maybe also spit out theMessage.xxxcomponents too. (One thing to watch out for here is that unless you are using Raw output then @ will HTML format your string - but that's not necessarily happening here)<p> @Model.HeaderCss </p> <p> @Model.HeaderId </p> <p> @Model.MessageId </p> <p> @Model.UserId </p>gives this: ` <p> sh_msg_GridAltItem sh_msg_MessageRead </p> <p> divHeader1 </p> <p> 36 </p> <p> {85A433F0-4054-42E7-B778-3EF005E411D3} </p>` Which is rightvar @(Model.HeaderId)_v1 = '@Model.HeaderCss';etc... then to call it:onclick="javascript:shMsgToggle(@(Model.HeaderId)_v1, @(Model.HeaderId)_v2, @(Model.HeaderId)_v3, @(Model.HeaderId)_v4)">YUK! :(