This example is designed to demonstrate how to generate
server side bar codes using the TALtech Bar Code ActiveX
control (Plus version). It uses an ASP generated HTML form
to collect information from the client about the type of
bar code they wish to create - including the bar code symbology,
the text to be encoded, the text for the comment, etc. When
the user completes the form, their information is submitted
to the server for processing. The ASP page then reads in
the client supplied parameters, generates the bar code and
saves it as an image file on the server. It then generates
HTML code containing an Image tag which references the newly
created bar code image. The generated HTML code is then passed
back to the users browser which displays the resulting bar
code.
It is not impossible that this example will work right "out
of the box" with little or no modifications on your
part, but don't be surprised if it does not. We have tested
it on a Windows 98 machine running Personal Web Server 4.0,
a Windows 2000 Server running IIS 5, and a Windows 98 Second
Edition machine running Personal Web Server 4.0. However,
this example is fairly complicated, there are many elements
to it and therefore some of it may not work on your server.
Usually if a line causes the script to fail an error is generated
and appears in the Browser window identifying which line
caused the problem, but it may still take some time to figure
out why it is not working. So instead of taking this example
and working backwards to fix the problems you encounter,
we recommend you start a new application that uses just the
basics and then build upon it, borrowing code and ideas from
our example until you have rebuilt the application in such
a way that not only does it work on your server, but it also
does exactly what you want it to do:
- Start with "Step1.asp" (included in the the
example files). This code generates a barcode (using the
default settings) with a hard coded filename (barcode1.png).
and displays this image on the page. (The image will be
huge because it is not being scaled to match your screen
resolution - more on this later).
- If you see the image, then add an HTML Form that allows
the user to specify properties of the bar code and the
code required to set those properties. If this step does
not work then there is no point having any other code!
See: Troubleshooting ActiveX and ASP Problems page
to help you figure out what is wrong.
- Once that is working you can add code that manages the
filenames - not necessarily the way we chose - perhaps
you would give the user the ability to name his own files.
- Add any other features you need.
Note: The ASP code in this example is recursive. In other
words the page contains logic so that it appears as a form
prompting for information about the bar code that you want
to generate the first time you view it. After you submit
the form, the page will rewrite itself to display the resulting
barcode.
Follow these steps to try to run the example "straight out of the box".
- Configure your Web Server to
run ASP and make sure your Web Server is running.
- Install TAL Barcode ActiveX Plus (or Demo) on your Web
Server.
Download
all the files discussed in this example. This is
a self extracting Zip file containing:
- "Barcode.asp" - the main (more advanced)
example discussed here.
- "Step1.asp" - a bare bones troubleshooting
or starter file.
- "Useful Code Snippets.txt" - Prewritten and
tested code that you should be able to cut and paste
into your application to enhance it with the minimum
of editing:
- Data Validation functions - catch errors before
they happen by checking that the barcode message
is suitable for the symbology selected.
- Code to Determine the client's Operating System,
Browser and Version - What if the client wants
to create a .png file but is using Netscape 4 which
cannot display it?
- Code to delete the old image files from your
server.
- Code to verify that the image you just tried
to create was actually created - Avoid broken links
that make your site look bad!
- "fnum.txt" - a simple text file that will
be used to track the file number.
- Double click on the downloaded file to extract the files.
(By default they will be extracted to your temp folder
("C:\Windows\temp" on Windows 95/98 machines
and "C:\temp" on Windows NT/2000 machines)
- Using Windows Explorer, copy the files into the root
directory of your web server (usually "C:\Webshare\wwwroot" or "C:\InetPub\wwwroot").
- Open your Web browser and type in "http://your.server.name/barcode.asp" into
the address line, change the properties that interest you
on the form, and submit it. You should be rewarded with
a barcode. If you are not, see: Troubleshooting ActiveX and ASP Problems.
View the Source Code behind
Barcode.asp (fully commented).
Note: The form contains more features than the supplied
ASP Code supports: Only the Message, Comment, Symbology and
Image Format properties will be set by the ASP Code. As an
exercise to help you understand how the example works you
may find it useful to make the other properties on the form
function too - this will help you learn to use both the ActiveX
Control and ASP.
Related Links
Introduction to Active Server
Pages
Printing From Active Server
Pages
Using TALtech Bar Code ActiveX
Plus with PERL CGI Scripts
See a fully
working ASP example of the TAL Bar Code ActiveX
Troubleshooting ActiveX and ASP
Problems
|