Questions tagged [asp.net-mvc-partialview]

A partial view enables you to define a view that will be rendered inside a parent view. Partial views are implemented like as user control in Asp.Net Web forms that is used for code re-usability. Partial views helps us to reduce code duplication.

917 questions
19
votes
5 answers

Clean way to return an empty mvc partial view

In cshtml file, based on a condition, what's the best way to return an empty partialview ? Right now I have: @if(Model.Count() > 0) { loooonng partial view block of markup code } How can I re-do it to look cleaner closer to…
InspiredBy
  • 4,152
  • 5
  • 36
  • 64
17
votes
2 answers

How to render partial view in MVC5 via ajax call to a controller and return HTML

How can use AJAX to load a complete partial view rendered in html (so I just set the div.html) I need the ajax call to call controller action that will render a complete partial view (red) and append it at the end of the currently loaded one? [I…
Paceman
  • 1,901
  • 3
  • 17
  • 26
16
votes
1 answer

Custom ActionResult equivalent Model for all PartialViews

I created following custom ActionResult which returns multiple partial views. public class MultiplePartialViewsResult : ActionResult { private const string Separator = "-"; private PartialViewResult[] _partialViews; public…
Maximus
  • 3,273
  • 3
  • 12
  • 26
16
votes
6 answers

.Net MVC Partial View load login page when session expires

I am building a web application using .net MVC 4. I have ajax form to edit data. If the user is idle for 15 mins it will expire the session of the user. When that happens if user click edit button it loads the login page inside the partial content…
15
votes
1 answer

A Partial View passing a collection using the Html.BeginCollectionItem helper

I made a small project to understand the answer from Stephen Muecke here: Submit same Partial View called multiple times data to controller? Almost everything works. The javascript adds new fields from the Partial View, and I can tell they're bound…
14
votes
2 answers

Javascript not working in Partial View

This problem is similar to what is described in Execute Javascript inside a partial view in ASP.NET MVC The below piece of code in index.cshtml is working fine... @Html.TextBox("locationOfSearch")
Suresh Ganapathy
  • 177
  • 1
  • 2
  • 11
13
votes
3 answers

Using paging in partial view, asp.net mvc

I'd greatly appreciate if someone could advise on following: In my view I display the list of items: @model PagedList.IPagedList @using PagedList.Mvc; @foreach (var item in Model) {//displaying data} my pager looks like…
Gyuzal R
  • 1,547
  • 7
  • 45
  • 92
11
votes
3 answers

MVC - Using Ajax to render partial view

I have this markup in an MVC app.
<% Recipe recipe = (Recipe)Model; %> <% Html.RenderPartial("IngredientsListControl", recipe.Ingredients); %>
<% using…
Malcolm
  • 11,020
  • 28
  • 85
  • 123
11
votes
2 answers

How to use partial view from another project in asp.net mvc

I have two MVC projects one as a parent project and the other as a child project. The child project adds reference to the parent project. I like to use partial views from the parent project from the child project something like…
lawphotog
  • 6,783
  • 19
  • 74
  • 121
10
votes
3 answers

How can I refresh just a Partial View in its View?

What Am I doing wrong guys? This is the idea... Index view
@Html.Partial("PartialView", Model)
Controller public ActionResult PartialView() { return…
Elias MP
  • 1,829
  • 9
  • 29
  • 47
9
votes
2 answers

ASP.NET MVC 4 generating a treeview with recursive partial view

I have a partial view in an MVC 4 project, which is strongly typed. It takes an IEnumerable collection of a table of a database. In that table there are IDs, Names, and ParentIDs for storing hierarchical connection between records. The view that…
9
votes
2 answers

Is it possible to kick off a javascript function after a partial view renders in MVC Asp.net?

Let me preface this question with the fact that I am very new to MVC. I have an instance where I am rendering a devexpress grid in a partial view. @Html.Partial("MyGridPartial", Model) I need to kick off a javascript function at the moment that the…
Bill Blankenship
  • 3,167
  • 5
  • 41
  • 71
8
votes
5 answers

asp.net mvc partialview @Ajax.ActionLink doesn't work

I have a view page my view page
@Ajax.ActionLink("please click on me to bring the partial view", "PatrialViewToBeCalled", new AjaxOptions() {UpdateTargetId…
Amir Jalali
  • 2,950
  • 4
  • 30
  • 43
8
votes
2 answers

Reporting errors from Ajax invoked PartialView methods in MVC

If a normal page load errors I can report the exception details to the user via the Error view and HandleErrorInfo model. If an ajax call expecting a Json result errors, I can explicitly handle the error and pass details to the client: public…
fearofawhackplanet
  • 47,230
  • 49
  • 149
  • 249
8
votes
2 answers

Razor views vs partial views

how does visual studio determine which is a view vs a partial view? Another question would be; is there a way to convert my views into partial views?
frank
  • 83
  • 1
  • 4
1
2
3
61 62