(919) 404-9327 sales@lizardwebs.net

Why use ASP scripting?

Using Classic ASP script

Using Classic ASP script

Scripting languages provide a method to add functionality and interactivity to your web pages.Simple HTML pages can be given added functionality with the addition of small chunks of code. ASP, ASP.NET and PHP are the primary scripting languages. ASP is a server-side technology as opposed to Javascript or ECMAScript which are generally used in client side applications. While Javascript can be used as a server side language, I think it’s far more common to use VBScript. Scripting provides the capabilty to add in formatting, tagging, and data that may be customized either to the browser or to the user. I’ve personally dragged on implementing any ASP.NET to this point. I never know when Microsoft is going to make yet another “paradigm shift” and obsolete this direction. It appears that they are going to stick with .NET for a while though, so I’ve started working in some .NET to my test sites.One can compensate for different browser behaviors with server side scripting. I frequently will use scripting to avoid those nasty things like browser incompatibility. Let’s say you’re working along on a great layout and then discover that a particular browser is NOT going to render a table or object the way it is really expected (read “Netscape 4.x”). You could either scrap the whole cool look…OR you could tell your asp page to spit out something along the lines of <table> for all browsers except NS 4.x, at which point you could churn out <table bgcolor="white" color="black" background="images/myImage.jpg">. Netscape just doesn’t handle CSS real well and I find it easier to just do a quick browser detection routine and customize the code to match the browser in my code as opposed to handling it client side with javascript.

As pointed out in other articles, scripting excels at doing repetitive things with a short bit of code. Let’s say you need a quick routine to churn out month names. We’ll use a built-in VBScript function to do most of the work.

 For iCnt = 1 to 12 Response.write MonthName(iCnt) & "<br />" & vbCrLf Next 'iCnt 

That’s it. 3 lines of code with returns and code returns in place. Now that’s only 12 items. Imagine if you wanted to do this more than once – maybe a calendaring application. Well, put it inside yet another loop set for the number of iterations you might need. THAT is the power of scripting.

 

When to NOT use ASP scripting

When it adds unneeded complexity. Write your code – be it HTML or scripting – to be as neat and clear as possible. If there’s a certain item that you will use more than once or twice, creating a routine is a very acceptable way to handle that need. If the item will only be used once, creating a routine to handle that one time action is overkill and is just one more routine to keep up.

This is sort of the “don’t use a sledgehammer” concept. If it takes only a couple lines of regular HTML to express the needed content, there’s really no use using 15 lines of ASP script to do it!

When your server is underpowered. If your site happens to reside on an overworked server or one that is really lacking in memory or processor speed, the parsing of the scripting can greatly chew up those resources. As the script starts allocation of variables, arrays, session values and the like, memory is set aside correspondingly. If your server is weak, this can GREATLY slow down the server and thus the site speed.
When your site is REALLY static. When creating a site, an evaluation of the site is important in determining if dynamic content is really going to be used. A good many sites out there just DON’T change that often and really do not NEED to be setup as an asp-centered page.

If you really want to get slick on these kinds of pages… You can actually create the page as an ASP page, view the page in your browser, then upload that as HTML. Make sure your links reflect that the pages are the .html version of the page. Thus if you have some content that IS dynamic, but changes VERY infrequently, you can harness the power of your server (and scripting) to create the output and then be able to serve easily handled straight HTML pages to your visitors. When changes are again needed, just regenerate the ASP page and upload the HTML again. An example of the usage of ASP pages in this manner is explained in ADO tips. This will reduce the load on your server GREATLY.