|
Step 12 :
Now go to File -> Make Stardeveloper.dll . A small dialogue window will open asking the name of DLL, by default Project
name which in this case is Stardeveloper.dll is used. But you should edit it so that it becomes 'CheckBrowser.dll'. And
then hit 'ok'.
If every thing goes fine then our component with ProgID 'Stardeveloper.CheckBrowser' will be created in the 'CheckBrowser.dll'.
On the next page we will create a simple ASP page and make use of our created component.
Create a new ASP page and name it 'checkbrowser.asp'. Copy and paste the following code into it
and then save it :
<html>
<head>
<title>
Stardeveloper.CheckBrowser Component.
</title>
<style>
body { font-family : Verdana; font-size : 10pt; }
</style>
</head>
<body>
<%
' Declaring variables
Dim objcb
Set objcb = Server.CreateObject("Stardeveloper.CheckBrowser")
' Using our component's methods to send browser speicific code to the client
If objcb.IsIE Then
' Browser is Microsoft Internet Explorer
Response.Write "Microsoft Internet Explorer specific code goes here..."
ElseIf objcb.IsNS Then
' Browser is Netscape Navigator
Response.Write "Netscape Navigator specific code goes here..."
Else
' Browser is neither Internet Explorer nor Navigator
Response.Write "Code for other browsers goes here..."
End If
' Done. Now destroy the objcb object
Set objcb = Nothing
%>
</body>
</html>
Now save the page in a directory from which you can run ASP pages. To run the ASP page e.g. if you have
saved the page in directory c:/inetpub/wwwroot/checkbrowser.asp then type http://127.0.0.1/checkbrowser.asp
in the URL box of your browser and hit 'enter'. Depending on the type of your browser you will see a browser
specific code message displayed on the browser. Try it out yourself and see it working.
Conclusion
We learned in this tutorial how to create a component and how to use ASP Intrinsic objects from within
the component. We made use of Request object in our methods to determine client browser. This tutorial will
have given you enough knowledge to start creating components which use ASP objects and you will have also
seen that it is very easy to create components in Visual Basic. Step 12 :
Now go to File -> Make Stardeveloper.dll . A small dialogue window will open asking the name of DLL, by default Project
name which in this case is Stardeveloper.dll is used. But you should edit it so that it becomes 'CheckBrowser.dll'. And
then hit 'ok'.
If every thing goes fine then our component with ProgID 'Stardeveloper.CheckBrowser' will be created in the 'CheckBrowser.dll'.
On the next page we will create a simple ASP page and make use of our created component.
Create a new ASP page and name it 'checkbrowser.asp'. Copy and paste the following code into it
and then save it :
<html>
<head>
<title>
Stardeveloper.CheckBrowser Component.
</title>
<style>
body { font-family : Verdana; font-size : 10pt; }
</style>
</head>
<body>
<%
' Declaring variables
Dim objcb
Set objcb = Server.CreateObject("Stardeveloper.CheckBrowser")
' Using our component's methods to send browser speicific code to the client
If objcb.IsIE Then
' Browser is Microsoft Internet Explorer
Response.Write "Microsoft Internet Explorer specific code goes here..."
ElseIf objcb.IsNS Then
' Browser is Netscape Navigator
Response.Write "Netscape Navigator specific code goes here..."
Else
' Browser is neither Internet Explorer nor Navigator
Response.Write "Code for other browsers goes here..."
End If
' Done. Now destroy the objcb object
Set objcb = Nothing
%>
</body>
</html>
Now save the page in a directory from which you can run ASP pages. To run the ASP page e.g. if you have
saved the page in directory c:/inetpub/wwwroot/checkbrowser.asp then type http://127.0.0.1/checkbrowser.asp
in the URL box of your browser and hit 'enter'. Depending on the type of your browser you will see a browser
specific code message displayed on the browser. Try it out yourself and see it working.
Conclusion
We learned in this tutorial how to create a component and how to use ASP Intrinsic objects from within
the component. We made use of Request object in our methods to determine client browser. This tutorial will
have given you enough knowledge to start creating components which use ASP objects and you will have also
seen that it is very easy to create components in Visual Basic.
|