Work with Web Sharp ActiveX in ASP
Here tech you how to start Web Sharp in ASP. If you want to know to the details of programming with Web Sharp, download the course.
Note: Source code of this demo is in the directory ¡°Demo\ASP\¡±, you can click here to download all the demos.
l Work with Web Sharp in ASP
1) Install Web Sharp pack. Click here to download.
2) Install and start IIS (Internet Information Server)
3) Create a template file named WebSharp.htm under web root such as C:\inetpub\wwwroot\WebSharp.htm with the following code:
<html>
<head>
<title>Web Sharp </title>
</head>
<body>
<font color="red">{%HeadLine%} </font>
<p>
<!--BEGIN LOOP: NumberBlock-->
{%Number%}
<!--END LOOP : NumberBlock -->
</p>
Please visit my homepage: <a href="{%URL%}">{%Text%}</a>
</body>
</html>
4) We provider a code produce tool called ¡°Code Framework¡± to make programming code automatically. It can produce most of the programming code. Run CodeFramework.exe, select asp.def from the languages combobox, and then click ¡°Open Template¡± button and select the template file WebSharp.htm, and then you will see the auto complete code result in something like the code in the following figure:

5) Save the framework code to file C:\inetpub\wwwroot\WebSharp.asp. Modify the framework code and result in the following code. The hightlight code in yellow is the modified result. What you do is only to fill the code framework with the actual data.
<%
Set WebTemplate=Server.CreateObject("WebSharp.WebTemplate")
WebTemplate.FileName= Server.MapPath("WebSharp.htm")
Set RootValueNode=Server.CreateObject("WebSharp.ValueNode")
StrHeadLine="This is my first Web Sharp ASP application"
RootValueNode.SetValue "HeadLine",StrHeadLine
'<!--BEGIN LOOP : NumberBlock -->
Set NumberBlockValueNode=RootValueNode.CreateChild("NumberBlock")
for I=1 to 15
Set NumberBlockValueNodeItem=NumberBlockValueNode.CreateChild("")
StrNumber= "Number"
NumberBlockValueNodeItem.SetValue "Number",StrNumber
Next
'<!--END LOOP : NumberBlock -->
StrURL="http://www.coolmasoft.com"
RootValueNode.SetValue "URL",StrURL
StrText="Coolmasoft"
RootValueNode.SetValue "Text",StrText
Response.Write WebTemplate.Rendered ( RootValueNode,"")
%>
6) Result in a web browser.

The whole development flow is very clear. After one person designs the web template, the other one continues to write the programming code. With the help of ¡°Code Framework¡±, programmers can save a lot of time.
If you do not use Web Sharp, you can open a new file C:\inetpub\wwwroot\normal.asp with the following code:
<html>
<head>
<title>ASP Demo</title>
</head>
<body>
</HEAD>
<body>
<%
StrHeadLine="This is my first Web Sharp ASP application"
StrURL="http://www.coolmasoft.com"
StrText="Coolmasoft"
%>
<font color="red"><%=strHeadLine%></font>
<p>
<%
For I = 1 To 15
%>
<%=I%>
<%
Next
%>
</p>
Please visit my homepage: <a href="<%=strURL%>"><%=strText%></a>
</body>
</html>
There are many <% or %> in the code and this code is not very easy to read. Of course, this is a very simple demo, you can¡¯t find out the advantage of Web Sharp. But if you develop a complex page without Web Sharp, you will be lost in the interlaced HTML code and ASP code, and then you will spend more time to find errors and bugs. ASP.Net technology can solve these in a certain extent, but you have to learn a lot of new components and engines in it. If one day you develop a web application with another language, you still have to learn a lot of new features of the strange language. What¡¯s more, when a new version of a programming language comes out, you have to learn the new features in it, too. Yet Web Sharp can avoid all these: perfect structure; learn once but benefit many programming languages.