如何在MVC View上呈现HTML [英] How can I render HTML on MVC View

查看:79
本文介绍了如何在MVC View上呈现HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我将HTML字符串存储在数据库中。我想将此HTML字符串呈现为页面上的元素。 HTML字符串中有一些Html.ActionLinks。我想要这个字符串完全转换为HTML元素。



下面是我的HTML字符串。

Hello,

I have the HTML string stored in database. I want to render this HTML string as elements on page. There are some Html.ActionLinks in the HTML string. I want this string to fully convert to the HTML elements.

Below is my HTML string.

<aside><h3>Aside Title</h3><p>Use this area to provide additional information.</p><ul><li>@Html.ActionLink("Home", "Index", "Home")</li><li>@Html.ActionLink("About", "About", "Home")</li><li>@Html.ActionLink("Contact", "Contact", "Home")</li></ul></aside>





我希望字符串@ Html.ActionLink可用作 -



I want the string @Html.ActionLink worked as -

<a href="/en/Home/Contact">Contact</a>





关于如何动态渲染MVC助手,请帮助我。



提前致谢。



Please help me regarding how to render the MVC Helpers dynamically.

Thanks in advance.

推荐答案

当我们在mvc中创建新的应用程序时,

我们在下拉列表中选择查看引擎..



ASPX Razor ...



如果您选择了 Razor 然后你使用@html.actionlink(联系方式,联系方式,主页)



你选择了 ASPX 然后



你可以像这样使用html控件...



when we have create new application in mvc that time
we select view engine in dropdown..

ASPX and Razor...

if You Have Select Razor then you have use @html.actionlink("Contact", "Contact", "Home")

and you have select ASPX then

you can use html control like this...

<a href="/en/Home/Contact">Contact</a>


您可以使用Html.Raw方法将字符串呈现为html标记。
You can use Html.Raw method for the rendering of the string as html tags.


这篇关于如何在MVC View上呈现HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆