1
I am developing a site with . net core and I am using Jquery. On the page Index.cshtml.cs
I have a function that has the validations and I pass the messages (if it is ok, if there was an error), through a string. Help me, because I’m new to . Net and I have no idea how to do.
I need, in Jquery, to take the value of this string to return the message handled.
I thank you all.
Code:
public async Task OnPostAsync(parametros)
{
....
await AtivacaoVerificarAsync2(Parametros);
//*Pegar o valor da mensagem aqui*
return;
}
public async Task AtivacaoVerificarAsync2(Parametros)
{
Mensagem = "deu certo";
return;
}
Jquery:
$(document).ready(function () {
$("#numeroSerie").focus();
$("#form-login").on("submit", function () {
$.ajax({
url: "https://localhost:44390/",
data: {},
complete: function (xhr, statusText) {
if (xhr.status == 200) {
alert(myValue);//*ALERTAR A MENSAGEM AQUI*
} else {
alert(myValue);//*ALERTAR A MENSAGEM AQUI*
}
}
});
});
});
I can’t use Scriptmanager.Registerstartupscript, because of the Scriptmanager error, saying that it doesn’t exist in the current context, and I can’t use System.Web.UI either.
To take a value of one
input
with jQuery just do $("id_ou_classe_ou_input[name='seuInput']"). val()– LeAndrade
but it is not the value of an input, which I need... I need the value of a string that is within a method
– Samuel Machado
No code available, no way to know.
– LeAndrade
I added a code base so you have a notion there, if you can help me I appreciate
– Samuel Machado
When you access https:/localhost:44390/, what does it return?
– thiago dias
it returns to my index page, normal
– Samuel Machado
Your project is ASP.NET Core Razor Pages?
– Rafael
@Rafael yes, he is
– Samuel Machado