Serevr.execute

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

Hi,

in classic asp I use server.execute method to execute asp code dynamic,
for example:

<body>
<% If Request.QueryString("file")="" Then %>
<% Server.Execute("main.asp") %>
<% Else %>
<% Server.Execute Request.QueryString("file") %>
<% End If %>
</body>

What is the most appropriate way to do the same in asp.net? Any idea or
examples?

Thanks,
Simon
 
Hi Mark,

thank you for your answer.

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.

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.

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? What about the performance if
you
have 10 user controls on one page?

Is there some other way, maybe http handler?

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?

Thank you,
Simon
 
ASP.NET bears *no relationship whatsoever* to Classic ASP. The best
advice I can give anyone moving from Classic ASP to ASP.NET is to
forget everything they ever knew about Classic ASP - none of it will
be of any use in ASP.NET. The biggest mistake people make is to
imagine that ASP.NET is somehow the "next version" of ASP. It isn't -
not even close. The reason for this is the .NET Framework.

I take this one step farther. If you are an ASP developer, switch to C# to
learn .NET. Why? The language change will blend with the paradigm change
and you will learn .NET, not how to write ASP style code in .NET.

After the paradigm change, you can switch back to VB and you will find that
you are writing better code than your buddies who moved from ASP to VB in
..NET.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
(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! |
*******************************************
 
But who on earth would want to switch from C# to VB...?

Those forced to write in VB by the company that hires them?

There are still companies that see going from ASP to VB (VB.NET if you
wish) as the proper upgrade path, thinking it saves them time, as there is
less learning curve.

Unfortunately, they often eliminate the language learning curve along with
the paradigm shift, throwing the proverbial baby out with the bath water.
But the gigs straightening out the mess generally pay well. ;-)

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top