Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 569297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:16:48+00:00 2026-05-13T13:16:48+00:00

EDIT I put my solution on a share site. Like that you’ll be able

  • 0

EDIT

I put my solution on a share site. Like that you’ll be able to see what I’m talking about. You can download it here : http://www.easy-share.com/1909069597/TestRenderAction.zip

To test it, start the project (let the create form empty) and click the Create button. You’ll see what happen.

It’s only a example project. I don’t care to persist my object to the database for now. I care to make my example work.

I got the following controller :

public class ProductController : Controller
{
    public ActionResult List()
    {
        IList<Product> products = new List<Product>();

        products.Add(new Product() { Id = 1, Name = "A", Price = 22.3 });
        products.Add(new Product() { Id = 2, Name = "B", Price = 11.4 });
        products.Add(new Product() { Id = 3, Name = "C", Price = 26.5 });
        products.Add(new Product() { Id = 4, Name = "D", Price = 45.0 });
        products.Add(new Product() { Id = 5, Name = "E", Price = 87.79 });

        return View(products);
    }

    public ViewResult Create()
    {
        return View();
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(Product product)
    {
        return View(product);
    }
}

The following model :

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public double Price { get; set; }
}

My Product/List.aspx :

<h2>List</h2>

<table>
    <tr>
        <th></th>
        <th>
            Id
        </th>
        <th>
            Name
        </th>
        <th>
            Price
        </th>
    </tr>

<% foreach (var item in Model) { %>

    <tr>
        <td>
            <%= Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> |
            <%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%>
        </td>
        <td>
            <%= Html.Encode(item.Id) %>
        </td>
        <td>
            <%= Html.Encode(item.Name) %>
        </td>
        <td>
            <%= Html.Encode(String.Format("{0:F}", item.Price)) %>
        </td>
    </tr>

<% } %>

</table>

<p>
   <% Html.RenderAction("Create"); %>
</p>

My Product/Create.ascx :

<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>

<% using (Html.BeginForm("Create", "Product", FormMethod.Post)) {%>

    <fieldset>
        <legend>Fields</legend>
        <p>
            <label for="Id">Id:</label>
            <%= Html.TextBox("Id") %>
            <%= Html.ValidationMessage("Id", "*") %>
        </p>
        <p>
            <label for="Name">Name:</label>
            <%= Html.TextBox("Name") %>
            <%= Html.ValidationMessage("Name", "*") %>
        </p>
        <p>
            <label for="Price">Price:</label>
            <%= Html.TextBox("Price") %>
            <%= Html.ValidationMessage("Price", "*") %>
        </p>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>

<% } %>

<div>
    <%=Html.ActionLink("Back to List", "Index") %>
</div>

The problem is that when I hit the create button and I got an error (like empty field), the return view only return my Create.ascx control. It’s doesn’t return the Product/List.asxp page with in my Create.ascx control with the errors. That’s what I would like it’s does.

Any idea how I can solve that problem ?

I use Asp.Net Mvc 1 with Asp.Net Futures (which have the Html.RenderAction).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:16:49+00:00Added an answer on May 13, 2026 at 1:16 pm
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(Product product)
    {
      ...
      return View("List");
    }
    

    or

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(Product product)
    {
      ...
       return RedirectToAction("List", "Product");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.