2eNetWorX :: Development Community with Tutorial, Script, Code, Programming sections for Visual Basic, Active Server Pages and .Net Framework Developers.  

Undocumented WriteBlock Code Sample - 2eNetWorX


Undocumented ASP WriteBlock function experimentation

 
  2eNetWorX :: ASP, VB, Asp.Net, Vb.Net, C#, dotNet, .Net OpenSource Projects
MyDev What's New | Projects | Tutorials & Articles | Services | Stats | Contact Us
Guest-16993    /dev :: home :: samples :: performance  596 online visitors
Popular Projects

  • TableEditor
  • StatCounteX
  • 2eNetWorX/Dev
  • MiniSurvey
  • OpenForum
  • PowerTool
  • ShopEZ
  • Trans-It
  • HiLiteR
  • (View All Projects)


    Top 10

    » Contributions


    Tutorials & Articles

    » Recordset Cache
    » OpenSource
    » Statisticus
    » OpenCYA!


    Code Samples

    » Undocumented...
    » Ask For Login
    » DSN'less Connection
    » Who's Online?
    » (All Samples)


    Link Back



    Site Banner


  • Code Samples :: Undocumented WriteBlock Feature

    There are various articles about performace saying that you should keep the number of switches between asp and html blocks at minimum. I agree.

    The new Asp.Net framework is said to have a new feature for performance called pre-compiling the Asp code. What the new engine does is to compile your asp page into a pcode binary format and cache it for faster execution. This is a clearly stated feature in the new Asp.Net framework.

    Do you know that the classic ASP engine does the same?

    The HTML blocks of your page is translated to ASP calls during the compiling, and then displayed using the undocumented WriteBlock function.

    Although WriteBlock function is meant to be executed by ASP engine, you can call it!

    The syntax is:

      Response.WriteBlock(BlockNumber)

    The following example is a mixture of asp and html blocks. When this page is first requested, it is compiled and cached.

    What output do you expect from the sample below?

    See it yourself, copy the following code into an asp page and test it!

    test.asp

    <html>
    <head>
       <title>Undocumented ASP Feature</title>
    </head>
    <body>

    <%

    response.write "executing at asp block #1<br>"

    %>

    html block 1
    <br>

    <%

    response.write "executing at asp block #2<br>"

    %>

    html block 2
    <br><br><br>

    <%

    response.write "Buffered HTML Blocks:<br><br>"

    response.write "<xmp>"
    for i = 0 to 3
      response.WriteBlock(i)
    next
    response.write "</xmp>"

    %>

    </body>
    </html>

    Keep in mind that number of WriteBlock's effect the performace of your asp page. The higher the number of html blocks you have, the higher the number of WriteBlock calls the ASP engine should execute.

    Having a Print function to Response.Write your html blocks gives a better performance. But then, you cannot design your html layout using a visual editor. Converting all the html code into Response.Write statements is another issue by the means of coding overhead.

    So, it's up to you to choose which way you go!

    For my opinion, performace usually suffers more because of wrong asp coding rather then having html blocks.

    This site uses html blocks as html, not Response.Write's :)

    I hope this sample gives you a quick overview of the pre-compilation and WriteBlock function.

    You are always welcome to express your feedback!

    by Hakan Eskici



    Who's Online

     Bot: Msn
     Bot: Google
     (407) guests
     (187) repeated

    How is this done?


    Popular Web Sites

      echoPANEL, Free .NET
      Webserver Control Panel

      FogBugz Hosting Plans
      SubVersion Hosting Plans
      SourceGear Vault
      Hosting Plans

    Admin's Toolbox

    Web Database Management
    Web Site Statistics
    Survey Manager
    Integrated forum for webpages
    OpenSource WebSite Framework


      privacy policy , license , disclaimer , © 2000-2004, 2eNetWorX.   [page generated in 516 ms.]