.net - How to Generate HTML from within ASP.NET MVC? -


My English is very awesome, so I can not understand the obvious

This is the controller

  Public Class Home Controller: Controller {Public Action Result Index () {View Data ["Message"] = "Hello ASP.NET MVC! "; See Data ["Author"] = "Author: Alex"; See Return (); }  

This is the view , this is a template.

  & asp: Content ID = "Content1" content placeholder id = "title content" runat = "server" & gt; Title  

& lt;%: View Data ["Message"]%>

& lt;% = ViewData [" Author "]%>

& lt;% = html.ActionLink (" This is a link. "," Index "," about ")%>

I use this template Want to generate the HTML file.

Alex

By generating HTML, I assume that you have programmatic meaning and are not referring to those scenes, which you can definitely put in HTML.

In the html assistant or controller, you can use the tagbilder to generate HTML. For example ..

Tagbilder Tag = New Tag Creator ("IMG"); Tag.Attributes.Add ("id", "myImage"); Tag Features. Add ("src", "/ content / images / soma_image"); Tag a quality. Add ("alt", "my image"); Tag a quality. Add ("width", "300"); Tag a quality. Add ("height", "300"); String html = tag. Toasting ();

You can also use HtmlTextWriter which is a bit similar.

  HtmlTextWriter author = new HtmlTextWriter (stream); Author.RenderBuginTag (HtmlTextWriterTag.Ul) // Dome Some Goods Writer.Renderendag ();  

etc.


Comments