开发者

User controls & Composite web server controls

开发者 https://www.devze.com 2023-01-31 23:05 出处:网络
Which approach should I prefer when it comes to writing a custom control in ASP.Net. Should I create a custom user control or should I create a Composite Web Server control. And how about adding a des

Which approach should I prefer when it comes to writing a custom control in ASP.Net. Should I create a custom user control or should I create a Composite Web Server control. And how about adding a designer support to the composite control. How are they different from 开发者_运维百科each other and their pros and cons.

Difference with an example of each will be preferable.


There is a comparison in the official documentation: Composite Control vs. User Control

I would go for a composite control if I plan to propose controls to other developers, like 3rd party controls vendors do. Then, I would add designer capabilities to these controls.

But, if I just want to develop controls that do custom things in a project, then user controls are easier to write, and require less ASP.NET inner knowledge.

Side note: Kothari's book is very good and a must read when developing composite controls, but it's not enough. Because it's an ASP.NET 1.1 book, there is no mention of very important notions that appeared in ASP.NET 2: the concepts of DataBoundControl vs DataSourceControl. All ASP.NET custom controls that appeared starting with .NET 2+, like FormView/GridView/DetailsView and ObjectDataSource, SqlDataSource, etc. are built on these fundamental concepts that are not covered in the book at all. Unfortunately, the book has never been updated, and I don't know of any other books that explain this with sufficient details.


Probably you need the following book

Developing Microsoft Asp.Net Server Controls and Components by Nikhil Kothari

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号