Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: ViewComponent bind attributes to public properties #54396

Closed
1 task done
abraluve opened this issue Mar 6, 2024 · 1 comment
Closed
1 task done
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages

Comments

@abraluve
Copy link

abraluve commented Mar 6, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Hi,

right now I have to declare ViewComponent using TagHelper like this:

<vc:my-component some-option="sample1" some-option2="sample2"></vc:my-component>

public async Task<IViewComponentResult> InvokeAsync(string someOption, string someOption2)

Describe the solution you'd like

<vc:my-component some-option="sample1" some-option2="sample2"></vc:my-component>

[ViewComponent(Name = "MyComponent")]
public class MyViewComponent : ViewComponent
{
    public string SomeOption { get; set; }
    public string SomeOption2 { get; set; }

    public async Task<IViewComponentResult> InvokeAsync()
    {
        //SomeOption..
    }

Additional context

My described solution is actually taken from ASP WebForms, it was clear and could be used outside method. Right now we have to pass variable to private methods.

Bonus of WebPart solution is that you dont have to provide all attributes/properties in HTML. It will use default values. Appending new parameter requires change at all locations if there is no default value, if you are not implementing model around it as single parameter.

Apologies if there is already duplicate.. I tried to search, probably mixed up keywords :)

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Mar 6, 2024
@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-blazor Includes: Blazor, Razor Components labels Mar 6, 2024
@martincostello martincostello added area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-blazor Includes: Blazor, Razor Components labels Mar 6, 2024
@captainsafia captainsafia added area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Mar 6, 2024
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
While this may be a great idea, it is not aligned with our long-term vision to make it part of the framework. For many other ideas which don't belong to the framework we encourage the community to build and ship on their own, contributing to the expanding .NET Ecosystem.

You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ui-rendering Includes: MVC Views/Pages, Razor Views/Pages
Projects
None yet
Development

No branches or pull requests

5 participants