A lot of web developers while learning ASP.NET get confused with the difference between an ASP.NET Page and ASP.NET User Control.
A User Control is a group of one or more ASP.NET Server Controls or HTML Controls that can be reused. So for example if you need to create a Login Control, you would group a bunch of TextBoxes, Label and Button Controls and create a User Control out of it. This User Control can then be reused on multiple pages, providing a Modular approach to web development.
User Control are similar to ASP.NET Web Pages (WebForm). User Control can have markup, code and script, just like Web Pages have. Since both the User Control and ASP.NET Web Page inherit from the TemplateControl class, they also share common methods and events.
However there are some basic differences between the two:
Tweet
2 comments:
Good Explanation....
A master page can contain zero or more master pages (nested master pages). However, it must be associated with one or more web pages (aspx) to be useful.
A web page can stand on its own. It does not need any master pages or user controls. It can also be associated with a master page and contain many user controls. It can also be viewed directly in a browser. A web page can dynamically load user controls at run time.
A user control (ascx) can exist on its own but can only be viewed by browsers when it is contained in a web page. A user control can contain zero or more user controls (nested controls).
So where does this leave us? Should i have a few web pages that load controls dynamically? Why not use the treeview as nav that has the control name as the url. When it postback it merely loads the control in the web page. Is it right or wrong... if it works does it matter!?! Alot of architecture is subjective and based on the architects frame of reference. The key things i find are, is it simple, can others understand it, does it scale, and does it make sense.
Post a Comment