asp.net-core-viewcomponent Questions

4

Can I use ViewComponents in a page like this. <vc:parent-component> <some random html> </parent-component> when I try this it renders out only parent component. In cshtml of p...
Perspicacious asked 17/3, 2019 at 11:59

1

On a Net Core 7 project I am rendering a View Component on a Razor page: <vc:footer></vc:footer> The component C# code is: public class FooterViewComponent : ViewComponent { public Fo...

3

Tag helpers render properly on ALL my razor pages but not in my ViewComponents For instance: <label asp-for="MiddleName" class="control-label"></label> should render as: <label ...

4

Solved

I have updated my asp.net core web application from 1.0.1 to 1.1.0, but tag helpers for my viewcomponents are not working: <vc:login-form /> it outputs the tag. It works using old syntax: ...

3

This weekend a lot of struggle with a View Component. I try to add a dropdownlist that does an auto postback onchange. This dropdownlist is on a view component. I have 2 problems: I don't get t...
Brusque asked 16/4, 2018 at 11:45

1

Solved

I am new to ASP.NET Core. I get this error when I use view component. Thank you for your help InvalidOperationException: Method 'Invoke' of view component 'UI.ViewComponents.NavbarViewComponent' c...
Eneidaenema asked 19/9, 2021 at 18:18

2

Solved

I am creating a set of View Components that represent filters on different views. They work great so far, but I don't understand this behavior I am experiencing. If I use declare two InvokeAsync: ...
Antoinette asked 26/5, 2017 at 19:23

7

Solved

I have tried adding a section script inside a view component's view. @section scripts { <script src="~/somepath" asp-append-version="true"></script> } I also have the Render Section...

3

Invoking a View Component as a Tag Helper was introduced in ASP.NET Core 1.1. (See “Invoking a view component as a Tag Helper”). But the following only returns the Test for VC part of the view. It ...

2

Solved

Im trying to Invoke ViewComponent using javascript to facilitate page loading,now i invoked viewcomponent using razor but the loading of page taking long time, how to do that? Here is the method i...

3

Solved

I'd like to define view components (which are new in ASP.NET MVC 6) in a separate assembly from the MVC 6 web startup project so that I can reuse them in multiple web projects. A sample solution mi...

1

Solved

I have a view component, EventsViewComponent, which is loaded in my Events view index.cshtml using the following lines of code: <div id="events"> @await Component.InvokeAsync("Events", new ...

1

I would like to bind a model expression (such as a property) to a view component—much like I would with an HTML helper (e.g., @Html.EditorFor()) or a tag helper (e.g., <partial for />)—and re...

1

Solved

It seems that in ASP.NET Core MVC, if I want to use a View Component, I have to put them in Views\Shared\Components\[ViewComponentName], and then name the file "Default.cshtml". This is r...

1

Solved

I have searched many places and have not seen anything similar to what I am thinking. Let's say I want to create a reusable container component, like a card, form, or a modal, and save that as a Vi...

2

Solved

In ViewComponent object, HttpContext and User are read-only properties. How to unit test such a component? I'm using the MSTest Freamwork. The follow properties are used in my code Cookie Ses...

2

Solved

Lets say I have a ViewComponent named MyComponent. As of ASP.NET Core 1.1 I can render this ViewComponent by writing this inside a razor view .cshtml page: <vc:my-component></vc:my-comp...
Epigram asked 5/4, 2017 at 8:25

3

I am trying to return a HTTP 500 or BadRequest() result from my View Component in Asp.Net Core however this return type does not appear to be available for View Components. Should status code retur...
Terrance asked 29/11, 2016 at 5:52

1

Solved

Trying to implement the layout of the picture below, I would like to ask about best practices regarding the architecture of the page layout. Is it better to have independent ViewComponents in every...
Grubstake asked 8/3, 2017 at 21:1

2

Solved

I have an ASP.NET Core 1.1 web application developed with VS.2017 and I decided to put some of the view functionality in a view component (have done others before). This view component fetches a D...
Diffident asked 29/6, 2017 at 19:5

2

I'm writing a custom TagHelper and want to render a ViewComponent inside it. Something similar to what vc:xyz tag helper does, but in a more controlled way, so that I can determine at runtime whic...

2

I am using the latest VS.2017 updates and templates for an MVC .NET Core web application. I decided I wanted ViewComponents in an external assembly since I read several posts that indicated it was ...
Likable asked 10/5, 2017 at 20:34

2

Solved

In ASP.NET 5 MVC6 RC1 - I have a ViewComponent which is designed to represent my traditional "left hand side of the screen" main menu. I am writing my first TagHelper to represent each menu item ...

1

I'm trying to create an async view component for ASP.NET Core 2.0. It will do an action that should be cancelled when the user navigates away from the page. I've got the following options: Using ...

2

Solved

I want wrap this: <textarea asp-for="@Model.Content" ...> into reusable ViewComponent, where property will be parameter: <vc:editor asp-for="@Model.Content" /> I was able to pass ...
Ivy asked 17/3, 2017 at 11:0

© 2022 - 2024 — McMap. All rights reserved.