239 questions
0
votes
1
answer
99
views
Questions regarding Tag Helpers and View Components
First of all I will start by apologizing for a messy question.
So I have been fiddling around with custom tag helpers and I need your thoughts. So far I've only extended simple tags like buttons and ...
0
votes
2
answers
228
views
ASP.NET Core view components returning blank pages
I have a view component I'm invoking like so:
@{
await Component.InvokeAsync("Edit", new { config = new List<EditConfiguration>() });
}
It looks like this:
// Need to make ...
-1
votes
1
answer
165
views
Could not find an 'Invoke' or 'InvokeAsync' method for the view component 'Shoes.Components.CartViewComponent'
I working on the View Component in ASP Net Core MVC. Here my view components
public CartViewComponent(GiaydepContext context)
{
_context = context;
}
public IViewComponentResult Ivoke()
{
...
0
votes
0
answers
81
views
Getting 500 Response on Ajax Call in Razor Page View Component
I am working on an ASP.NET 7 project where I have a Razor page, and I have used Ajax to call the GET method from the C# file.
I am calling the GET method from the CSHTML using Ajax to CSHTML.CS. There,...
0
votes
1
answer
150
views
ViewComponent Not Found from class library .Net 6
I have an issue using a .Net 6 Class Library to create ViewComponent to use it many Web app.
I have create a Class library :
The code :
public class HelpComponent : ViewComponent
{
public ...
0
votes
2
answers
531
views
How to refresh data displayed in ViewComponent's default View : ASP.NET MVC Core
I have a razor view that is divided into two columns. The column on the left contains a list of bootstrap list-group-items ( job cards). On the right is a larger column to display the full details of ...
0
votes
0
answers
79
views
Rendering ASP.NET Core MVC ViewComponents as soon as the model is ready
I am using an ASP.NET Core MVC ViewComponent to show similar content but with different data.
My index page looks like below (I am calling around 15 ViewComponents and passing some arguments to each ...
2
votes
1
answer
457
views
Is there a way to nest things inside a view component (written as a tag helper) in ASP.NET?
I want to do something like this...
<vc:sidebar-submenu id=@configurationId>
<vc:sidebar-submenu-item action-name="Index" controller-name="MapDefinitions" text="...
0
votes
1
answer
97
views
.NET Core 7.0 how to Pass static parameter
I currently working for the UI part, I would like to create a template html to use it globally for every pages.
I would like to know how to pass a static text string to view components:
ViewComponent/...
0
votes
2
answers
861
views
How to Redirect to a view from a viewcomponent while passing a value via URL?
I have a following method inside a viewcomponent
public async Task<IViewComponentResult> InvokeAsync (ToolModel model)
{
if (!ModelState.IsValid)
{
...
0
votes
0
answers
355
views
How to execute the viewcomponent and read the viewcomponent's parameters from the controller?
I am using the below code to execute view component in .cshtml
@await Component.InvokeAsync("FileUpload",Model)
Inside that view component, there is a file uploader.
After select a file ...
0
votes
0
answers
129
views
How to load a ViewComponent in JavaScript dynamically?
I am trying to invoke a ViewComponent by calling a controller action in JavaScript, but it gives this error:
NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load ''.
and
Failed ...
0
votes
1
answer
439
views
How to download the coverted doc file from viewcomponent?
I have a view component which do file upload.
public async Task<IViewComponentResult> InvokeAsync (ToolModel model)
{
if (!ModelState.IsValid)
{
return View();
...
4
votes
1
answer
3k
views
When to use partial view and ViewComponent?
I am beginner for asp.net core. I am building file conversion website. PNG to JPG, PDF to Word etc.. In there I amusing fileuplaod control to upload content for the conversation.
Instead using same ...
13
votes
1
answer
2k
views
Why View Component is not rendered in production?
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 ...
0
votes
1
answer
562
views
Asp.NET core, AJAX doesn't work at all in my project
I started a Razor Pages project and I need to use AJAX so that I can refresh my comments section without refreshing my entire page. unfortunately AJAX does not seem to work at all, it's as if the code ...
0
votes
1
answer
475
views
I created class library in .net6.0 and added my ViewComponent.I want to access my viewcomponent Default page in asp.net core mvc application
Hi I created my classlib and added my viewcomponents to that library and I added DLL file of my class library to asp.net mvc application I can able to use class and models but I don't know how to ...
0
votes
0
answers
149
views
The model item passed into the ViewDataDictionary is of type 'Castle.Proxies.xxProxy', but this ViewDataDictionary
I think I have an interesting model conflict between controller and viewcomponent. I couldn't solve the problem. I leave my Controller and Component codes. Raw exception details right below
...
0
votes
0
answers
451
views
Razor Page with dynamic form
Having recently migrated from years of web forms, I’ve built numerous dot net core razor page apps - So I’m not a complete beginner but I am struggling to understand the best way to approach one ...
0
votes
1
answer
281
views
Custom View Components Folder configuration
Using Net.Core 7 I have a few View Components which are located in:
/Pages/Components/Component1/Default.cshtml
/Pages/Components/Component2/Default.cshtml
...
I want to place all views in Components ...
0
votes
1
answer
1k
views
pass parameter to View Component after table row click
Inside a normal View, we are populating a table via the model with this:
@foreach (var item in Model)
{
if (item.PartnerSubscriptionID > 0)
{
<tr id='[email protected]....
0
votes
1
answer
792
views
ASP.NET Core 6 - using memorycache in view component
I am writing an application using ASP.NET Core 6 MVC.
I have a controller that instantiates an IMemoryCache and stores some values into the cache.
public HomeController(ILogger<HomeController> ...
0
votes
0
answers
348
views
Single razor page with dynamically loaded child pages/partial views/viewcomponents?
I'm admittedly relatively new to razor pages and I'm trying to understand how best to approach this particular use case. The application will ultimately be one that has many (potentially +100) ...
0
votes
1
answer
1k
views
ViewComponent must have one public method named 'InvokeAsync' or 'Invoke' - ASP.NET CORE (.NET 6)
I am now designing a website using .NET6 and unlike older versions of ASP.NET Core, this version doesn't have methods like @{Html.RenderPartial("_ViewNamePartial")} so I'm using ...
0
votes
1
answer
859
views
ASP.NET Core MVC Problem with a View Component
I have the following view component:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace InfinityVS22N6.Views....
0
votes
1
answer
253
views
ASP.NET View Component Fails to Load in Linux
My web application runs perfectly fine in Windows. I even have it running in production on a Linux server for years without issue.
Now that I try to open the solution on a Linux desktop with JetBrains ...
4
votes
2
answers
1k
views
ASP.NET Core specific way to reuse Edit and New view content in cshtml
I have a New and Edit view that basically contain duplicate cshtml. What's the most efficient way to refactor so I can stay DRY?
I already looked through Stack Overflow, and all the answers I could ...
1
vote
2
answers
747
views
Searching paths for ViewComponent in ASP.NET
In general if we use View("Index"). It will search for views in Views/ControllerName or Views/Shared folder. Likewise if we use Component.InvokeAsync("SomeData") then what are the ...
1
vote
0
answers
259
views
ViewComponents from another project not working
I'm using ASP.Net Core 5.0 for a web application in which I'm using ViewComponents. The ViewComponent classes are defined in another project. The main project has too many views so I added:
<...
2
votes
1
answer
597
views
Notyf View Component Not Working When Using Environment Tag
In my dotnet 5 MVC web application, I'm using THIS ToastNotification library for showing notifications. It's working good since long. As documentation says, it requires following line in _Layout file
@...
0
votes
1
answer
699
views
when using ajax to load a view component the view components javaScript Codes doesn't work
i used a view Component that has some javaScript codes for animations.
when page loaded javaScript works well but when click a button to load data with ajax,
data loaded correctly but javaScript codes ...
1
vote
0
answers
1k
views
How to Send POST requests in View Components
I am currently working on an ASP.NET Core 6.0 MVC application (with Entity Framework), and I am trying to be able to perform CRUD operations without refreshing the page. As far as my research has ...
0
votes
1
answer
629
views
get simple data like string in viewcomponent in c#
Hi I have a viewcomponet that read text from a txt file and i want to show that text in viewcomponent
this is my ViewComponents ".cs"
public class MainFooterViewComponent:ViewComponent
{
...
0
votes
1
answer
349
views
C# .net core - Nested Div with ID on button press load, but works on normal load. ViewComponent
I have a view component in my view and it works properly when its loaded one time. This view is part of a Slideshow so there are buttons on it. When the user clicks the next button it creates a ...
0
votes
1
answer
1k
views
How return a yaml file as result of an asp.net core ViewComponent
I want to create an asp.net core ViewComponent that dynamically return a yaml file based on some criteria:
For example
namespace MyNameSpace {
[ViewComponent(Name = nameof(MyViewComponent))]
public ...
0
votes
1
answer
354
views
ViewComponent does not render on _Layout file
I have added a ViewComponent <vc:my-profile-menu /> in the _Layout file. On the development computer, it displays correctly, but when I deploy it to the server, it does not render. In the ...
0
votes
1
answer
966
views
More than one IViewComponentResult method in ViewComponent Class
Is it possible to access more than one IViewComponentResult method in a single ViewComponent Class? I seem to be able to create more then one method with each referencing their own View, but I have ...
2
votes
2
answers
3k
views
.NET CORE Invoke ViewComponent from Controller
I am having issues with loading a ViewComponent from a controller, my main view is Contact.cshtml and my ViewComponent is AddContact.cshtml. AddContact is a simple form with a submit button, I am ...
1
vote
1
answer
2k
views
How to get object from ViewComponent on post?
On my razor page project, I am using a View Component as a template for listings, like so in my html:
@foreach (var listingItem in Model.ListingItems)
{
@await Component.InvokeAsync("...
1
vote
2
answers
2k
views
ASP.NET Core : view component with 2 invokes
I have many view components and used in a Page Maker software.
But now I need make a dynamic setting page for each view component.
Something like this:
@Component.InvokeAsync("Image");
@...
2
votes
1
answer
158
views
Remove the naming convention rule for finding ViewComponents
As per the documentation the following rules determine whether a class is a ViewComponent:
Deriving from ViewComponent
Decorating a class with the [ViewComponent] attribute, or deriving from a class ...
1
vote
1
answer
966
views
Using JavaScript to append a ViewComponent to a Div
Is something like this possible? I have a ViewComponent and I'd like to use JS to call it and apply it to a DIV.
<script>
// Get the side menu
var sideMenu = document....
0
votes
1
answer
313
views
.Net Core 5 ViewComponent Model on cshtml is always null
I'm working on some ViewComponent but when I try to Access the Model in the cshtml file it's always null.
Here is a very simple example that has this problem
This is the .cs code
[ViewComponent(Name = ...
2
votes
2
answers
1k
views
Display ViewComponent in shared _Layout, only on certain pages
I have this ViewComponent in my shared layout:
@if (User.Identity.IsAuthenticated)
{
<vc:room></vc:room>
}
Is there a way to only have it render if the user is on a certain page, or ...
0
votes
1
answer
3k
views
View component refresh on button click in Razor Pages
I'm using view components to render a list of strings in HTML. The component has a button that when clicked, should toggle which list of strings is shown. When the button is clicked, only the view ...
1
vote
1
answer
1k
views
Override Invoke method in an inherited ViewComponent .net core 5.0
I'm migrating from ASP.NET MVC to ASP.NET Core MVC.
I had a BasePodsWidgetController that looked like this:
public abstract class BasePodsWidgetController<TProperties, TConfiguration, TItem> : ...
0
votes
1
answer
1k
views
Pass model Property to Razor View Component
I'm working on the Razor View components and I used below code to define view component.
View :
@using MyLibrary.Models
@model InputComponentModel
<label [email protected] class="control-...
5
votes
1
answer
3k
views
I get this error when I use view component
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' ...
0
votes
0
answers
793
views
Could not find an 'Invoke' or 'InvokeAsync' method error in razor views
When using view components in my views I am getting this error which doesn't make sense. When I open up a view that uses a view component (calling the tag helper for said view component), I am seeing ...
0
votes
1
answer
1k
views
Modal Window in Net Core with ViewComponent
i have the problem with Modal Window open with JQuery. I don't call the function. The same Code with normal Page is open normaly but the call function inside viewcomponent don't call.
the razor Page ...