简体   繁体   中英

How to render a view into another one, after an ajax request in C# and ASP.NET MVC?

I'm new at programming using ASP.NET MVC with C#. My problem is the next, I have a form to do an advanced search, that send every field in an ajax request. In the controller I receive all information and then I save it into a SQL table. I can Access this search in another view by accessing the corresponding URL, for example searches/viewSearch/123 . What I need is to render the view just after I saved the search in my table, in the same view where I have my form.

My recommendation is to use Partial Views . Move your table to a partial view, your view can then load that partial view via Ajax when you want to access the corresponding url. You can also use

@{
    Html.RenderPartial("_yourpartialview");
} 

instead of an ajax call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM