Wednesday, 30 August 2017

How to render Html tags which are inside string in MVC razor

n this tutorial I will show you that how can you how can we render html tags in the string in MVC3 razor.
Example of the string is
string abc = “this is htmlstring”;
this can be rendered in razor using html.raw tag now after launching of the MVC3 RC2 that means you dont have to use
@MvcHtmlString.Create(ViewBag.HtmlOutput)
or
@(new HtmlString(ViewBag.HtmlOutput))
or anything else to output a string containing HTML in ASP.NET MVC.
So tag can be written as ….
@html.raw(abc);
This will render your html tag.
string abc = "this is <b>html</b>string";
@html.raw(abc);
This is how we can render html tags in MVC3 razor

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...