1
I’m using Asp.net-mvc and as far as I know the Onload event would work if I put in body, which is in ~Layout, but I need this alert to be displayed in a single page, because if I put in body will run every time... how can I do?
code of the View:
@model Tribus.Models.Pagamento
@{
var Id = Session["PacoteID"];
}
<script type="text/javascript">
$(document).ready(function () {
//window.onload = window.alert("entrou aqui");
window.onload = function () {
var id = $(this).attr(Id);//id do item
window.alert(id);
var url = '@Url.Action("RetornoRegistrar", "Pagamento")';
$.post(url, { id: id },
function (data) {
window.alert("Registrado com Sucesso\nLogo seu produto será liberado.")
});
});
});
</script>
Can you explain better "displayed on a single page"? you mean on a specific page or only once for each user?
– Sergio
This would be a page that the user would pass, during a process and when he enters this screen, the alert is fired at him. I just wanted to know how to call the function when loading this page.
– Fabio Souza
@Sergio put the page code
– Fabio Souza