开发者

Asp.Net MVC - RenderPartial - Create in a List view

I got a page that lists all my articles (Articles/List.aspx).

I also got a control that create article (Article/Create.ascx).

I will like that my List.aspx page that's render the Create.ascx to be able to create article.

I know that in MVC, the preferred approach is one page by action. But in this case I need to do that. It's a design issue and how the client want the Web site to work.

So for now, I got the following code in List.aspx :

<% Html.RenderPartial("Create", new Domain.Models.Article()); %>

That render correctly. But when I hit the create button, it's doesn't go in the Create[post]开发者_如何学JAVA method of my ArticleController.

Any idea why and how I could resolve that issue ?


If you have problems with the button, it's not going to have anything to do with how you're rendering the user control. We need to see the form markup that the button is inside, that will show what the problem is most likely.

But just for reference, you're probably looking to do something like this:

<% using (Html.BeginForm("Create", 
    ViewContext.RouteData.Values["Controller"].ToString())) { %> 

    your control markup here

<% } %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜