2
I searched a lot on Google and Youtube, but I didn’t find anything very clear(I might be searching wrong too). I’m new to Asp.net, and wanted to pass the data from this form (Works.cshtml) to the model (Works.cshtml.Cs) Works.cshtml:
<form asp-controller="Admin" asp-action="Trabalhos" method="post">
<h1>Novo<span>:</span></h1>
<h3>Título do post<span>:</span></h3>
<input type="text" id="titulo"/>
<br />
<h3>Postagem<span>:</span></h3>
<textarea id="textoPost" style="resize:none;"></textarea>
<button id="BotaoEnviar" type="submit">Enviar</button>
</form>
Works.cshtml.Cs:
namespace Elo.Pages
{
public class AdminModel : PageModel
{
public void Formulario()
{
string titulo = Request.Query["titulo"];
string textoPost = Request.Query["textoPost"];
StreamWriter a = new StreamWriter(@"C:\Users\Mateus\Desktop\Nova pasta\linhas.txt");
a.WriteLine(titulo + textoPost + "<-- deu isso aqui");
}
}
}