The first thing I have to do in here is to apologise for not posting something on this blog for a long time. Yes it was really a long time without any posting. There were some reasons for that like I had to go abroad (still I am at Canada, and it is a big experience). So I was new in here had lot of work to do. Anyway I hope to post regularly now onwards.
I have been on 2 projects in here (web applications). On one project it was designed to do by using more “User Controls” and the other one was using “Custom Controls” so first of all I was pretty confused with mixing these two approaches. In my mind I was like in a war to identify what is the better approach and thought to write about those a little.
Basically a User Control is like a normal aspx page only different I can see is the file extension is as ascx. We can make a user control and it has a code behind also. We can just build this as a web page and treat it as a normal web page on aspx. So we can have properties and methods on the code behind and can have all the controls as on aspx and HTML.
User Controls can be built as a reusable thing for a project and we can insert on several places on a particular project. For example we can build a Form or some contents with styles. Since we can dynamically assign the properties it can used on many places and helps maintains the uniformity. So when an aspx page is built then it will be a collection of user controls and an assignment of properties for them.
User controls were developed even though it is used only on one place. They were maintained as user controls because we can use them when a change or an enhancement is needed. The other thing is we can just publish the user controls on MOSS. Since the project I was on which had user controls were published on MOSS so we haven`t done any aspx page and all the user controls were either directly published on MOSS or used by another User Control.
In this URL below you can find more I mean more on how to develop a user control. To understand when and where to use them it is needed to do some hands on experiments.
A custom control is basically a class. It derives from Control or WebControl. So what we are doing is making some control that is reusable on any project. What usually made are customized Data grids (like editable grids), Date Time pickups, and textbox with AJAX suggestions. Since these are Classes we can use the dlls on anywhere. (Even on another project easily)
It can either be inserted on an aspx page directly or on a User Control. What I am thinking is making a lot of complex Custom controls that only can be used on one project is not worthy unless we are reusing it more and more (on same project). And it will be better we can make more generic Custom Controls that enhances the functionality of aspx controls. (It is what happens on most software companies)
You can find on how to develop a new custom control and insert it on an aspx (or ascx) by visiting the link below.
On the other project we were using the custom controls and they were just put on the aspx pages. The custom controls we were built was a bit complex ones (and used once inside the project and specialized for the same project). So there were about 2-3 custom controls per page. I think it will be better if we are using both control types on a web application and the custom controls should be compatible with other projects and user controls may be more specified for a particular project.
I know that I don`t have a lot of experience on these so if there is some more information or something need to be changed please let me know.