Library tutorials & articles
Beginning Active Server Pages
Forms
Now you know the basics of ASP, we'll take a look at another aspect of Active Server Pages - collecting data. In HTML, any page that has a textbox or other form of input has a Form tag - even a Search engine uses forms. Once the fields have been filled in by the user, the information is 'posted' to another location. This can be a CGI script, compiled DLL, ASP Page, or simply an email address in the form of a mailto: link.
Before we set about dealing with the data that is sent to an ASP page, we need
to know how to collect it. So, we'll have a quick look at the HTML tags required
for a Form. First, you need a form tag. This tells the browser
where to post the data, and how to do it:
<form action="mypage.asp" method="POST">
</form>
(Note that all the other form fields must be in between these two tags in order
to be posted to mypage.asp. Next, you need to specify some fields. This most
often done with an input tag (there are a few exceptions, but we
won't deal with them here - take a look at the options in your HTML editor).
The tag takes the form
<input type="InputType" name="FieldName"
value="InitialValue">
InputType is usually Text - a text box, or Hidden
- a field which is not displayed on the page. FieldName is a unique
ID for this field. When retrieving the data after it has been posted, you need
to know this FieldName value. InitialValue is the
value of the field before the user makes any input (such as the Text property
of a VB textbox).
Finally, you need a button or image for the user to click on to submit the data. This is usually in the form
<input type="submit" value="Button Caption">
If you want to use an image as the button, use
<input type="image" src="PathtoImage">
For our example, we're going to collect information for becoming a new member of our fictional site. To do this we're going to create single ASP page to collect the information, and then process it. For accessing data
First, add the following code to an ASP page named forminput.asp. At the moment, all it does is collect the data.
<form action="forminput.asp"
method="POST">
Your Name <input type="text" maxlength=20 name="Name"><br>
Your Email <input type="text" maxlength=100 name="Email"><br>
<input type="hidden" name="Posted" value="1">
<input type="submit" value="Sign Up">
</form>
As you can see, first we include a form tag. Next, we include two text boxes for the Name and Email. We have set the input fields maxlength property, so we don't get any users trying to enter anything longer than we want. Next, we have a hidden field called 'posted' (this is explained later), and finally a submit button with its caption set to "Sign Up".
Related articles
Related discussion
-
Header and Footer in Web page print
by fhajaj (4 replies)
-
Run-time error '91'
by crazyidane (0 replies)
-
Problem handling Redirects with MSXML2.XMLHTTP
by brandoncampbell (2 replies)
-
vbinputbox pauses code while it waits on response. How can I reproduce that?
by brandoncampbell (1 replies)
-
help me to get simple requirement
by Slicksim (1 replies)
Related podcasts
-
ASP.NET Caching and Performance
Steve Smith, owner of ASP Alliance and Lake Quincy Media joins us today to teach us about some hidden gems in ASP.NET caching and performance. Steve’s expertise in this area comes from first-hand experience as Lake Quincy’s ad system serves over 60 requests per second and handles over 150 million...
Hi,
When I say I'm an ASP beginner, I mean it! I've only written one trivial bit of code, and got a blank page. I see now that's described in the article snippet below. I did indeed go to the saved .asp page on my hard drive!
So my questions:
I have XP, so IIS is presumably installed. In the snippet below, are 'localhost' and c:\inetpub\wwwroot the actual strings to type in? For example, I currently don't have a folder called "inetpub". Do I have to create one? And where on my actual server (starman.co.uk) should I put any ASP pages?
Alternatively, is there a good introductory book you can recommend?
http://localhost/orhttp://PCName/. The physical location of your web site is by defaultC:\inetpub\wwwroot. Save your ASP pages there, and view them in a browser by visiting the URLs above.hi,
its first i started ASP.I want to know how to save the files.whats the extensions...Where can i get the sample programs
Are you running IIS ? And are you viewing it in your browser via the correct URL? (ie something starting with http:// rather than file:// ) ?
It does - you just can't see it
We've got an ISAPI filter that rewritse /show/1010/ to something like /show.aspx?id=1010
Is there something special I have to do besides saving it as a .asp file, or does it just not work on my server? It just spits out the code, even HTML, as plain text.
Let's see if ASP works!<br>
<%
Response.Write "Yep!"
%>
</html>
"The VB code can act on information passed to the page, such as from an internet form or a querystring (this is data passed in the URL after the ? ... take a look at this pages URL!)"
http://www.developerfusion.com/show/1010 doesn't have a question mark in it...
you can not include a file from a remote storage site other than the one your website is being hosted on , like writing <!--#include file = " www.someplace.com/somefile.inc " --> but by using asp tear codes you can if you have any support this features.
What do I do if I need to include a file from a remote storage site other than the one my website is being hosted on. The following doesn't work anymore
<!--#include file = " www.someplace.com/somefile.inc " -->
or even less the " virtual " call which starts searching the virtual directory the website is stored on.
What now?
Do I need to write a routine to access the file remotely then spilling it onto the page using response.write???
The trick for this is to get .NET to generate a TLB library for your the .NET class. In Vs.NET, you can modify the current build profile and set the "Register for COM Interop" section to true. See http://www.c-sharpcorner.com/Code/2002/April/COMInteropP2AJ.asp for more information.
hi all,
I am very new to ASP technology.
I am in a need to use DLLs (written in C#) in ASP Pages.
Could anyone suggest me how to proceed.
Regards,
MAK,
thanks, but it wasn't the sql. i did that. it's long since solved.
chk your SQL statement. Stop before execting cConn.Execute sSQL . Print sSQL and try executing the same in the backend. If it doesnt work then you need to change the SQL statement.
i solved the problem a while ago, but i forgot how.
heppens to be that i have the same prolem.
I'm beginner of ASP.I make my thesis with ASP.But I've got problem for building project in Visual InterDev.I'd already installed IIS5.It shows web server can't connect.How I do?If it's cause of IIS error,please explain me step by step.let me know solution during five days.please help me.
It doesn't work it all. I created the table using Access and set of the OBDC fine. What's wrong?
I get this error when I submit forminput.asp:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Unknown
/forminput.asp, line 12
What's wrong? I even copied the code over exactly.
the error's with this line:
cConn.Execute sSQL
I tried this code out exactly, but I get an INSERT INTO syntax error. I have also tried using the rs.AddNew to add to my database but I get a read-only error. I have tried changing the lock type and cursor types around but I can't get anything to work.
pls see t he comment
U Have to include a file name adovbs.inc file i yr asp page. thenu can use the addnew and update methods
I tried this code out exactly, but I get an INSERT INTO syntax error. I have also tried using the rs.AddNew to add to my database but I get a read-only error. I have tried changing the lock type and cursor types around but I can't get anything to work.
One thing to note, this only works on pages which have been posted to
This thread is for discussions of Beginning Active Server Pages.