रेंडर करने के लिए मैं एक MVC अनुप्रयोग में इस मार्कअप है।MVC - अजाक्स का उपयोग करते हुए आंशिक दृश्य
<div id="ingredientlistdiv">
<% Recipe recipe = (Recipe)Model; %>
<% Html.RenderPartial("IngredientsListControl", recipe.Ingredients); %>
</div>
<div id="ingrediententrydiv" align="left">
<% using (Ajax.BeginForm("Add Ingredient", "Recipes/UpdateStep2", new AjaxOptions { UpdateTargetId = "ingredientlistdiv" }))
{ %>
<p>
<label for="Units">Units:</label><br />
<%= Html.TextBox("Units", 0)%>
<%= Html.ValidationMessage("Units", "*")%>
</p>
<p>
<label for="Measure">Measure:</label><br />
<%= Html.TextBox("Measure")%>
<%= Html.ValidationMessage("Measure", "*")%>
</p>
<p>
<label for="IngredientName">Ingredient Name:</label><br />
<%= Html.TextBox("IngredientName")%>
<%= Html.ValidationMessage("IngredientName", "*")%>
</p>
<p><a href="javascript:document.forms[0].submit()">Save Ingredient</a></p>
<%= Html.Hidden("RecipeID", recipe.RecipeID.ToString())%>
<% } %>
</div>
जब यह चलाता IngredientsListControl.ascx ब्राउज़र में एक नया पृष्ठ displayas और ingredientlistdiv अपडेट नहीं होता।
यह मेरा नियंत्रक कार्रवाई
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateStep2(FormCollection form)
{
var factory = SessionFactoryCreator.Create();
using (var session = factory.OpenSession())
{
Recipe recipe = GetRecipe(session, Convert.ToInt32(form["RecipeID"]));
Ingredient ingredient = new Ingredient();
ingredient.UpdateFromForm(form);
ingredient.Validate(ViewData);
if (ViewData.ModelState.Count == 0)
{
recipe.Ingredients.Add(ingredient);
session.Save(recipe);
return PartialView("IngredientsListControl", recipe.Ingredients);
}
return Content("Error");
}
}
Am मैं इस लाइन पर सही काम कर रही है?
return PartialView("IngredientsListControl", recipe.Ingredients);
कि मैं कैसे div में नियंत्रण प्रस्तुत करना तो यह है नया पृष्ठ को लोड नहीं है। ???
मैल्कम
से फोन हम हमेशा आंशिक नाम के लिए पूर्ण, एप्लिकेशन-रिश्तेदार पथ का उपयोग किया है, उदाहरण के लिए Html.RenderPartial ("~/दृश्य/होम/ModuleNewUser.ascx") –
यह एक नया पृष्ठ के रूप में आंशिक प्रदर्शित है? या कुछ अन्य पेज? आपके आंशिक सामग्री क्या है? –