Asp.net mvc 3 如何使用jTemplate将字符串呈现为html

Asp.net mvc 3 如何使用jTemplate将字符串呈现为html,asp.net-mvc-3,jtemplates,Asp.net Mvc 3,Jtemplates,我正在使用asp.net C MVC将公告集合绑定到视图中的模板。 其中一个公告的html字符串与其描述中的相同 现在的问题是如何将该字符串呈现为html 我的观点是 <textarea id="dashAnnoucement_Template" data-template-name="dashAnnoucement_Template" class="hidden"> {#foreach $T as Announcement} <li id='{$T.An

我正在使用asp.net C MVC将公告集合绑定到视图中的模板。 其中一个公告的html字符串与其描述中的相同

现在的问题是如何将该字符串呈现为html

我的观点是

<textarea id="dashAnnoucement_Template" 
       data-template-name="dashAnnoucement_Template" class="hidden">
{#foreach $T as Announcement}
   <li id='{$T.Announcement$iteration}'>
   {#if !$().compare($T.Announcement.Category,
          @Convert.ToInt32(UI.Entities.AnnouncementCategory.RichText))}
      <div  class="card large flipped">
      <div class="pic">
      {#if $T.Announcement.LinkOff} 
         {#if $T.Announcement.Image.IsVideo}
           <a href="{$T.Announcement.LinkOff.Target}" class="play">
             <span>{$T.Announcement.Image.AltText}</span>
             <img alt="{$T.Announcement.Image.AltText}" 
                  src="{$T.Announcement.Image.Source}" class="thumb"/> 
           </a>
         {#else} 
           <a href="{$T.Announcement.LinkOff.Target}">
             <img alt="" src="{$T.Announcement.Image.Source}" class="thumb"/> 
           </a>
         {#/if} 
      {#else} 
        <img alt="" src="{$T.Announcement.Image.Source}" class="thumb"/>      
      {#/if}                       
      </div>
      <div class="content"><h3>   
      {#if $T.Announcement.LinkOff}                  
        <a href="{$T.Announcement.LinkOff.Target}" 
           target="{#if $T.Announcement.LinkOff.IsExternal}_blank{#else}_self{#/if}">
          {$T.Announcement.Title}</a>
      {#else}      
        {$T.Announcement.Title}                           
      {#/if}
      </h3>
      <p>{$T.Announcement.Summary}</p>
      </div>
      </div>
   {#else}
      {$T.Announcement.Description}
      @*Need to render this as html*@
   {#/if}
   </li>
{#/for}
</textarea>
我的Json数据,即announcementsCollection

[   {     "Category": 1,     "Title": "White Space Announcement Title",     "Description": "",     "Summary": "Join us Fri,April 24 in Atlanta,GA to mingle with Solavei members & hear top earner success stories",     "Image": {       "Source": "http://slvdev.blob.core.windows.net/media/1463/whitespace_1.jpg",       "AltText": "",       "Target": "",       "IsVideo": false     },     "Date": "\/Date(-62135596800000)\/",     "LinkOff": {       "Target": "http://solavei.com/",       "Text": "Learn More >",       "IsExternal": true     }   },   {     "Category": 1,     "Title": "Got Questions?",     "Description": "",     "Summary": "Access Member Support for information on your phone, your Solavei Membership, and your Solavei Mobile Service.",     "Image": {       "Source": "http://slvdev.blob.core.windows.net/media/7323/equipment-support-224x168.jpg",       "AltText": "",       "Target": "",       "IsVideo": false     },     "Date": "\/Date(-62135596800000)\/",     "LinkOff": {       "Target": "http://support.solavei.com",       "Text": "Learn More >",       "IsExternal": true     }   },   {     "Category": 4,     "Title": "html",     "Description": "<div class=\"imageBox shadowBox\" style=\"float: right; margin: -20px -20px 0px 20px;\">                                            \t                        <a target=\"_blank\" href=\"https://support-uat.solavei.com\">\t\t                        \t\t                        <img class=\"fullImage\" alt=\"\" src=\"http://slvdev.blob.core.windows.net/media/35985/neon.jpg\" style=\"height:170px\">\t                        </a>                                                                  </div>\n<div class=\"contents\">                                                            <h2>                                                    <a target=\"_blank\" href=\"https://support-uat.solavei.com\">                                                    Rich text                        </a>                        </h2>                                                                        <p>Access Member Support for information on your phone, your Solavei Membership, and your Solavei Mobile Service.</p>                                            </div>",     "Summary": "<div><img src='https://slvdev.blob.core.windows.net/media/35985/neon.jpg' wid/>\n<p>Test Message</p></div>",     "Date": "\/Date(-62135596800000)\/"   } ]

我知道这是一个老帖子但是, 首先,您必须将JSon数据转换为Html代码,然后 使用Html.Raw将代码显示为Html

[   {     "Category": 1,     "Title": "White Space Announcement Title",     "Description": "",     "Summary": "Join us Fri,April 24 in Atlanta,GA to mingle with Solavei members & hear top earner success stories",     "Image": {       "Source": "http://slvdev.blob.core.windows.net/media/1463/whitespace_1.jpg",       "AltText": "",       "Target": "",       "IsVideo": false     },     "Date": "\/Date(-62135596800000)\/",     "LinkOff": {       "Target": "http://solavei.com/",       "Text": "Learn More >",       "IsExternal": true     }   },   {     "Category": 1,     "Title": "Got Questions?",     "Description": "",     "Summary": "Access Member Support for information on your phone, your Solavei Membership, and your Solavei Mobile Service.",     "Image": {       "Source": "http://slvdev.blob.core.windows.net/media/7323/equipment-support-224x168.jpg",       "AltText": "",       "Target": "",       "IsVideo": false     },     "Date": "\/Date(-62135596800000)\/",     "LinkOff": {       "Target": "http://support.solavei.com",       "Text": "Learn More >",       "IsExternal": true     }   },   {     "Category": 4,     "Title": "html",     "Description": "<div class=\"imageBox shadowBox\" style=\"float: right; margin: -20px -20px 0px 20px;\">                                            \t                        <a target=\"_blank\" href=\"https://support-uat.solavei.com\">\t\t                        \t\t                        <img class=\"fullImage\" alt=\"\" src=\"http://slvdev.blob.core.windows.net/media/35985/neon.jpg\" style=\"height:170px\">\t                        </a>                                                                  </div>\n<div class=\"contents\">                                                            <h2>                                                    <a target=\"_blank\" href=\"https://support-uat.solavei.com\">                                                    Rich text                        </a>                        </h2>                                                                        <p>Access Member Support for information on your phone, your Solavei Membership, and your Solavei Mobile Service.</p>                                            </div>",     "Summary": "<div><img src='https://slvdev.blob.core.windows.net/media/35985/neon.jpg' wid/>\n<p>Test Message</p></div>",     "Date": "\/Date(-62135596800000)\/"   } ]
@Html.Raw("Your html in here")