0
I have the following page cshtml
@using SoftluxWebCore.ViewModels.Tabelas
@model SoftluxWebCore.ViewModels.Tabelas.MensagemViewModel
<!-- Link to CSS -->
<link href="~/css/Geral/create.css" rel="stylesheet" />
@using (Html.BeginForm())
{
using (Html.DevExtreme().ValidationGroup())
{
@Html.AntiForgeryToken()
<div class="divFormulario">
<textarea cols=60 id="opiniao" rows="10" name="men_mensagem" maxlength="500" wrap="hard" placeholder=""></textarea>
</div>
<br />
<button type="submit" class="btn btn-success btn-sucesso"><i class="far fa-check-circle"></i> Gravar</button>
<button class="btn btn-danger btn-cancelar" onclick="parent.fecharJanela('CadastroAmbiente')"><i class="far fa-times-circle"></i> Cancelar</button>
}
}
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
This is the page update
, she has methods get
and post
in controller
, when I do the post, it sends me the right way, sends to men_mensagem
which I defined in the attribute name
, but when I do the get
, the textarea
comes empty, how can I do to bring the data?
My method of controller:
[HttpGet]
[Route("Mensagem/Update/{Men_codigo}")]
public async Task<IActionResult> Update(int? Men_codigo)
{
int? Emp_codigo = Services.Token.strEmp_codigo;
var UrlApi = $"api/Mensagem/find/{Men_codigo},{Emp_codigo}";
Uri BaseAdress = Services.Token.BaseAdress;
string strToken = Services.Token.strToken;
MensagemModel Ambiente;
MensagemViewModel AmbienteVM = new MensagemViewModel();
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = BaseAdress;
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", strToken);
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("Application/Json"));
using (HttpResponseMessage response = await httpClient.GetAsync(UrlApi))
{
response.EnsureSuccessStatusCode();
string resul = await response.Content.ReadAsStringAsync();
Ambiente = JsonConvert.DeserializeObject<MensagemModel>(resul);
AmbienteVM.Men_codigo = Ambiente.Men_codigo;
AmbienteVM.men_mensagem = Ambiente.men_mensagem;
}
}
return View(AmbienteVM);
}
Worked out though and how do I set number of rows, columns, maximum number of characters and other things ?
– Jeff Henrique
I fixed the answer by adding how to put attributes to textarea.
– Gustavo Luciano