ASP. net mvc: HTML string, asp. netmvc

Source: Internet
Author: User

ASP. net mvc: HTML string, asp. netmvc

Some html after HtmlEncode, such as"& Lt; span & gt; Test Data & lt;/span & gt;". Now you need to display the content normally in the asp.net mvc view.


For example, create a model first:

 

Create a controller:

 

You can implement it in the view by using the @ Html. Raw () method.

 

View the results:


 

Or you can move the HttpUtility. HtmlDecode () method to the Controller.

Then, in the view, use the @ Html. Raw () method only:

 

The above is just usedRazor syntax. If you use jQery to present data, how can you implement it? In fact, the implementation has not changed much, but it is more simple. Next, Insus. NET creates another view and uses jQuery to render the string after Htmldecode.

In the controller, add an Action operation and a Method:

 

Create View:

 

The running results are the same.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.