Follow another example that can be done by .aspx.Cs(Codebehind)
using System.IO;
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Cliente> lstCliente = new List<Cliente>
{
new Cliente{ Id = 1, Nome = "Cliente1"},
new Cliente{ Id = 2, Nome = "Cliente2"},
new Cliente{ Id = 3, Nome = "Cliente3"},
new Cliente{ Id = 4, Nome = "Cliente4"},
};
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Ul); //Cria a tag ul
foreach (Cliente cliente in lstCliente)
{
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Li); //Cria tag li
htmlWriter.Write(string.Concat(cliente.Id, ": ", cliente.Nome));
htmlWriter.RenderEndTag(); //Fecha tag li
}
htmlWriter.RenderEndTag(); Fecha tag ul
ltListaClientes.Text = stringWriter.ToString();
}
}
In the .aspx I added a literal to receive the list
<asp:Literal id="ltListaClientes" runat="server" />
Yes, your project is MVC or Webforms?
– Jéf Bueno
He is in Webforms
– Lucas Sousa
Are you using Razor or aspx?
– Jéf Bueno
I’m not wearing no
– Lucas Sousa
Sorry guy, yesterday I was already leaving the company, I’ll try to do today, so I try I put here whether I got it or not, thank you !
– Lucas Sousa
I made it, thank you very much!
– Lucas Sousa