Questions tagged [partial-views]

User control in Asp.Net Web forms that is used for code re-usability. Partial views helps us to reduce code duplication . Reusable views like as Header and Footer views .

Partial view is like a regular view with a file extension .cshtml. We can use partial views in a situation where we need a header, footer reused for an MVC web application. We can say that it’s like a user control concept in ASP.NET.

2715 questions
0
votes
1 answer

ASP.NET Core MVC Master Detail in partial view

I am trying to do CRUD operations on a Master Detail model Department and Employee using modal popup. This is the code I used: DepartmentController: [HttpGet] public IActionResult Create() { Department department= new Department(); …
0
votes
0 answers

Why is my cshtml being broken by partial tags within an if statement block?

Probably quite simple, but I'm new to C# and Razor, and I'm having trouble finding an answer. I have multiple links across my project that I want to display through partials. 95% of them are absolutely fine. However one sits within an @if block.…
James
  • 1
  • 1
0
votes
1 answer

Loading PartialView refreshes entire page using AJAX

At the core, I am trying to generate a table with links that can be clicked on a reload of a PartialView. Everything is working except I cannot get the page to stop refreshing. What I would like to do is only load the PartialView inside of the…
JL1
  • 309
  • 2
  • 18
0
votes
1 answer

Pass current model to a Partial View in ASP.NET Core

I am working on an ASP.NET Core MVC application and i want to make CRUD operations using Modal popup. I used this code to display the Edit partial popup: Index.cshtml: @model IEnumerable @{ ViewData["Title"] =…
0
votes
2 answers

ASP.NET Core 6 MVC ajax render view in Body Section

I am creating an ASP.NET Core 6 MVC application. In my _Layout.cshtml I have a menu that the option calls a method in the controller that renders a View in @RenderBody() Simplifying, the menu is like this
  • Diego
    • 2,238
    • 4
    • 31
    • 68
  • 0
    votes
    1 answer

    Logic for Partial Views Used Across an App

    How do I associate a PartialView which will be used across the app with a Child Action? For example the PartialView could be a login bar at the top of the page which will need to have some associated logic (loading the model etc) which I would…
    Judo
    • 5,167
    • 3
    • 24
    • 34
    0
    votes
    1 answer

    ASP.NET Core 6 Partial View "InvalidOperationException"

    I want to show my create view into my main view which is index. So I take a partial view which is _Create.cshtml. But after calling the partial view, I get an InvalidOperationException. This is my index.cshtml: @model…
    0
    votes
    1 answer

    Devexpress mvc gridview in NavBar

    I want to have navbar with 2 groups and gridview in each group. My gridviews are in partial views I use them like this: Html.RenderPartial("ManagersGridPartial", Model) Problem that i cant add partial view in…
    Andriy Khrystyanovich
    • 1,422
    • 3
    • 19
    • 38
    0
    votes
    1 answer

    Common Content Partial View

    I have a tag cloud that I'm including on nearly all of the views that I have in my site. I realize that I can put it on a master page. The bigger question is, how do I pass it the data from the database? I'd like to avoid having to fetch the data…
    Darthg8r
    • 12,377
    • 15
    • 63
    • 100
    0
    votes
    1 answer

    Using PartialView to create dynamic MainMenu in _Layout Page - Asp.net core razorpage

    i want to using PartialView in My _Layout Page and this is my PartialView code: @model List @foreach (var item in Model) {
    0
    votes
    1 answer

    many little partials take up lot's of time to render, why, and how can I speed this up?

    I have some 'boxes' that use a javascript scrolling library to display content. The box contains 4 visible content nuggets like this:

    pixelearth
    • 13,674
    • 10
    • 62
    • 110

    0
    votes
    1 answer

    Razor page views with Partial (nested) views

    I broke down bigger "Razor page" views into to "Partial" views. From the main views I pass e.g. an image list to the partial view: These partial views now starts to grow, and gets less…
    Asons
    • 84,923
    • 12
    • 110
    • 165
    0
    votes
    1 answer

    Calling HtmlHelper's extension method from within a PartialView

    I'm trying to call a custom HtmlHelper's extension method from a partial view <%: Html.ToRelativeTime(Model.CreatedDate) %> and I get this error: CS1061: ...does not contain a definition for 'ToRelativeTime' and no extension method 'ToRelativeTime'…
    Ken D
    • 5,880
    • 2
    • 36
    • 58
    0
    votes
    1 answer

    How to use @Html.Partial() directly on a page in MVC 3

    I want to use @Html.Partial("_partialView") to include a partial view on my page in MVC 3. Both the page and the viewmodel have a viewmodel; thus, the following error is generated: The model item passed into the dictionary is of type '[...]page',…
    Helge
    • 823
    • 5
    • 13
    • 28
    0
    votes
    0 answers

    Binding partial view to razor page model

    I have a ASP.NET Core Web Application, using RazorPages. I'm using a partial view for searching for a person. This partial view model (base PageModel) has a constructor with an interface to supply a repository (using DI). This partial view model…