question

82475081 avatar image
0 Votes"
82475081 asked YijingSun-MSFT edited

Reusable UI Component

Hi,

How to build reusable UI Component( not class library) that can be used in multiple project ( different project & solution), in a project we could create Partial view can be reused, but how to use the same component in multiple web projects

What are the best option we have in .net framework 4.8


Regards,
ultimate

dotnet-aspnet-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

While with web forms you could build user controls (in their own project) and share between projects), MVC 5 (4.8) does not have a good option. Typically you use project templates (which copies files) or you can create custom html helpers, but they will not have post back handling. Html helpers are pretty easy to create.

In .net core, for MVC you use tag helpers or view components. For razor, you use razor components to create reusable UI components that can built into their own project.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered YijingSun-MSFT edited

Hi @82475081 ,
What's type of your project? Webform? If your project is mvc,you could build custom MVC template this may match your requirement or you could use asp.net core.
Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.