ASP.NET ascx vs. aspx - Do you reuse user controls?

后端 未结 4 2370
孤城傲影
孤城傲影 2021-02-20 07:26

Our team is developing a rather big ASP.NET web project which initially started in ASP.NET 1.0 and was ported several times to all new versions of .NET.

We made extensiv

4条回答
  •  佛祖请我去吃肉
    2021-02-20 08:26

    We have some projects which use ASCX controls extensively, and others that don't. In my experience you have to decide on a case by case basis.

    My two favourite reasons for using ASCX controls are:

    1. You're implementing a piece of UI functionality which will appear on many different pages (or multiple times on the same page).
    2. You want to encapsulate some complex functionality to keep it distinct from the rest of the page, thus making your code easier to read and more maintainable.

    ASCX controls can be useful, but you really need to make sure you only use them when there's a good reason to - otherwise - as you say, you can be adding unnecessary complexity into your codebase.

提交回复
热议问题