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.
Questions tagged [asp.net-mvc-partialview]
917 questions
304
votes
5 answers
ASP.NET MVC 3 - Partial vs Display Template vs Editor Template
So, the title should speak for itself.
To create re-usable components in ASP.NET MVC, we have 3 options (could be others i haven't mentioned):
Partial View:
@Html.Partial(Model.Foo, "SomePartial")
Custom Editor Template:
@Html.EditorFor(model =>…
![](../../users/profiles/321946.webp)
RPM1984
- 69,608
- 55
- 212
- 331
180
votes
9 answers
Pass Additional ViewData to a Strongly-Typed Partial View
I have a strongly-typed Partial View that takes a ProductImage and when it is rendered I would also like to provide it with some additional ViewData which I create dynamically in the containing page. How can I pass both my strongly typed object and…
![](../../users/profiles/143327.webp)
Nathan Taylor
- 23,720
- 17
- 90
- 152
95
votes
6 answers
How to pass parameters to a partial view in ASP.NET MVC?
Suppose that I have this partial view:
Your name is @firstName @lastName
which is accessible through a child only action like:
[ChildActionOnly]
public ActionResult FullName(string firstName, string lastName)
{
}
And I want to…
![](../../users/profiles/811785.webp)
Saeed Neamati
- 33,583
- 40
- 128
- 183
79
votes
4 answers
asp.net MVC partial view controller action
I'm very new to web app development and I thought I would start with recent technology and so I'm trying to learn asp.net as-well as the MVC framework at once. This is probably a very simple question for you, MVC professionals.
My question is should…
![](../../users/profiles/167511.webp)
yogibear
- 12,787
- 8
- 27
- 30
73
votes
7 answers
How can I load Partial view inside the view?
I am very confuse with this partial view.
I want to load a partial view inside my main view.
Here is the simple example.
I am loading Index.cshtml of the Homecontroller Index action as a main page.
In index.cshtml, I am creating a link…
![](../../users/profiles/927002.webp)
patel.milanb
- 5,450
- 14
- 52
- 86
62
votes
2 answers
MVC Html.Partial or Html.Action
I am new to asp.net MVC so please bear with me. I need build a menu that repeats across multiple views. What would better serve the purpose Html.Action OR Html.Partial.
![](../../users/profiles/1110437.webp)
developer747
- 13,032
- 22
- 78
- 136
55
votes
2 answers
MVC Form not able to post List of objects
so I have an MVC Asp.net app that is having issues. Essentially, I have a View that contains a form, and its contents are bound to a list of objects. Within this loop, it loads PartialView's with the items being looped over. Now everything works up…
![](../../users/profiles/929919.webp)
Sonoilmedico
- 1,333
- 1
- 9
- 9
53
votes
8 answers
A public action method '..' was not found on controller '..'
I wanted to put a random image on every viewpage of my mvc project. So i created a method that returns a partialView and call that method in the shared Layout page.
This works fine when I try to login with a correct username and password. The used…
![](../../users/profiles/2339024.webp)
Gijs
- 815
- 1
- 13
- 22
41
votes
2 answers
What is the correct place for Partial Views in ASP.NET MVC?
Would someone confirm the best place for a partial view in ASP.NET MVC?
My thinkings are if it's a global view that's going to be used in many places then SHARED.
If it's part of a view that's been wrapped up into a partial view to make code reading…
![](../../users/profiles/457172.webp)
Martin
- 22,234
- 53
- 190
- 309
25
votes
2 answers
ASP MVC Define Section in Partial View
As the title states, I want to define a section in a partial view.
My code that I've tested with are as follows:
Controller:
public ActionResult Test()
{
return View();
}
public ActionResult PartialTest()
{
return…
![](../../users/profiles/1581026.webp)
Jeandre Pentz
- 962
- 2
- 9
- 20
25
votes
5 answers
How to render a Section in a Partial View in MVC3?
In a MVC3 project, I have a "_Layout.vbhtml" file with this code
...
@RenderSection("Scripts", false)
…
![](../../users/profiles/478045.webp)
Max
- 4,469
- 15
- 44
- 61
23
votes
3 answers
How to send model object in Html.RenderAction (MVC3)
I'm using MVC3 razor, and I'm trying to pass an object to a partial view, and it's not working.
This works fine without sending the object model to the partial view:
Html.RenderAction("Index", "ViewName");
Trying this doesn't sent the model object,…
![](../../users/profiles/1044803.webp)
Michael
- 287
- 1
- 2
- 10
21
votes
4 answers
HtmlHelper extension method vs partial view?
I curious when it's recommended to use HtmlHelper extension method and when to use partial view? They seem to be equally eligible in many cases.
![](../../users/profiles/11256.webp)
Alexander Prokofyev
- 32,090
- 32
- 91
- 115
21
votes
6 answers
Pass viewbag to partial view from action controller
I have a mvc view with a partial view.There is a ActionResult method in the controller which will return a PartialView. So, I need to pass ViewBag data from that ActionResult method to Partial View.
This is my Controller
public class…
![](../../users/profiles/1758309.webp)
cp100
- 1,353
- 5
- 17
- 35
20
votes
3 answers
pass a different model to the partial view
I am trying to pass a different model to the partial view from a view. I have two separate controller actions for both of them and two different view models. But when I call the partial view from within the view it gives me the error
The model item…
![](../../users/profiles/3541362.webp)
user3541362
- 299
- 2
- 7
- 16