(e-mail address removed):
When you use server.execute in asp, you include part of page, so that
is
not just server-side code, but also html elements. The similar as
include statement.
And you can segment out your code base in ASP.NET, as well. One option
is user controls. For example, let's say you use an address on many
different forms. Create an address.ascx control and then include it in
the proper place on the forms.
If it is truly a "control", server controls are more reusable. For
example, you need a contorl that only accepts input in a certain format
(phone number, etc). By making it a compiled control, you get the drag
and drop ability from the toolbar (NOTE: The same can be true of ASCX
once you compile the web application, although they appear on a
different part of the toolbar).
So, If I put this part of page into some class module, I must create
HTML(or web) controls dynamic? I think that class module is just for
server side code, not for generating parts os page.
Not necessarily:
http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx
The similar as asp server.execute in asp.net is web user control as I
understand - it has html controls and appropriate server side code.
Isn't that the most appropriate way?
it is one way and it is a very easy way. With a user control, you drag
and drop on a "page" and then include on the ASPX page. It follows the
same model.
What about the performance if
you
have 10 user controls on one page?
The performance issue is not the same as adding tons of server.execute
statements in classic ASP, where you can have a serious degradation of
performance. The JIt compiler will compile the controls at roughly the
same speed whether they are in the ASPX page proper or in a ASCX user
control thrown on the ASPX page. JIT compiling is JIT compiling.
Is there some other way, maybe http handler?
HTTP Handlers are designed to alter the flow of the ASP.NET engine.
While you might kludge up a "control" or "set of controls" with a
Handler, it is NOT the proper method.
So, I need to create dynamic page, which consists for example of 10
parts (10 small pages
) and each part can be on many pages.
I should use user controls or something else?
You need a "page" that has 10 parts that may or may not show?
If the parts are determined by the user, perhaps a web part is the best
method. This is very good for portal situations.
If it is based on data, then server controls (compiled) or user controls
can work. If user controls, you might want to read this:
http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls
The main decision point for controls is reuse, at least in most cases.
If you are not reusing the bits, think carefully about how you will
segment out the "app".
Another option is a variety of panels dragged on the page and
"dynamically" showing the ones you need. This can be better, in some
cases, where you only use the 10 "options" on a single page. This is
useful if the pieces show up on the page in a specific order, like top
to bottom and is not always the best "dynamic" option.
The point here is the app should determine the best course of action.
How are you using the controls? Portal style? Dynamically adding based
on data? Dynamically adding based on user input? Dynamically adding
based on steps (multi-part form)? Other?
Peace and Grace,
--
Gregory A. Beamer (MVP)
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************