je moi principale comme ceci:Ajax demande pour aller chercher vue partielle
<% @ Page Titre = "" Language = "C#" MasterPageFile = "~/Vues/Shared/Site.master" Inherits = » System.Web.Mvc.ViewPage » %>
Index
<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<h2>
Index</h2>
<script type="text/javascript">
$(function() {
$('#mylink').click(function() {
$('#resultpartial1').load(this.href);
return false;
});
});
$(function() {
$('#mysecondlink').click(function() {
$('#resultpartial1').load(this.href, { id: 123 });
return false;
});
});
</script>
<%= Html.ActionLink("click me","Partial1","Foo",new MyViewModel { Foo = "123" , Bar="456" },new { id = "mylink" }) %>
<%= Html.ActionLink("click me second link","Partial2", "Foo", new { id = "123" }, new { id = "mysecondlink" }
)%>
et contrôleur comme ceci:
public class FooController : Controller
{
//
// GET: /Foo/
public ActionResult Index()
{
return View();
}
public ActionResult Partial1(string id)
{
// TODO: use the id to fetch the model from somewhere
MyViewModel model = new MyViewModel { Bar = "a", Foo = "1" };
return View(model);
}
public ActionResult Partial2(string id)
{
// TODO: use the id to fetch the model from somewhere
MyViewModel model = new MyViewModel { Bar = "b", Foo = "2" };
return View(model);
}
}
}
offre une vue partielle comme celle-ci:
<% @ Control Language = "C#" Inherits = "System.Web.Mvc.ViewUserControl" % >
Foo: Bar:<% @ Control Language = "C#" Inherits = "System.Web.Mvc.ViewUserControl "%>
Foo: Bar:Je suis toujours reçois des valeurs fixées par les actions du contrôleur. Je veux définir les valeurs en vue et passer en vue partielle. Comment puis-je faire ceci ?
toute solution/indice pour cela? – asif
qu'est-ce que vous avez jusqu'ici? pouvez-vous poster du code? –
J'ai une vue où j'ai besoin de deux liens. et j'ai deux vues partielles et une classe de modèle. – asif