File.cshtml is found as follows:
<html>
<head></head>
<body>
<!-- Nesta div pretendo abrir minha popup -->
<div id="popup"></div>
<!-- Com este link pretendo acionar a abertura da popup -->
<a id="open">Abrir PopUp</a>
<script type="text/javascript">
$("#open").click(function () {
$.ajax({
type: 'GET',
url: '/Usuario/arquivoFilho',
success: function (data) {
$('#popup').html(data);
$('#popup').show();
}
});
});
</script>
</body>
</html>
As I'm working with ASP.NET MVC, when I write: url: "'/Usuario/arquivoFilho',"
in method $ajax()
, I'm saying that I have a user name controller and inside it an Action (function / method) as follows:
namespace WebApplication1.Controllers
{
public class UsuarioController : Controller
{
public ActionResult arquivoFilho()
{
return View();
}
}
}
This action arquivoFilho()
, redirects by default to the view "File.Cshtml" (This redirection happens because I created the view from the method), which has the content that I want to display in the popup. The file "File.cshtml" is found as follows:
<html>
<head></head>
<body>
<h2>Editar Usuário</h2>
@using (Html.BeginForm("Index", "Usuario", new { ReturnUrl = ViewBag.ReturnUrl },
FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.HiddenFor(x => x.login)
<div class="editor-label">
@Html.LabelFor(model => model.login)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.login)
@Html.ValidationMessageFor(model => model.login)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.senha)
</div>
<div class="editor-label">
@Html.EditorFor(model => model.senha)
@Html.ValidationMessageFor(model => model.senha)
</div>
<p><input type="submit" value="Save" /></p>
}
</body>
</html>
The fact is that it is not working.