Codefixer - ASP tutorials, resources and software
ASP.NET Hosting with US & UK Data Centers!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Sunday 7 September
MembersPro PayPal - ASP Membership software

New MS SQL 2008 Available – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Pass Hidden form values in ASP

Below highlighted in red is what the HTML for a hidden form value looks like. As you can see it's almost the same as the HTML form textbox below it. The major difference is that the hidden form value isn't visible to the user.
<input type="hidden" name="hasdonelogin" value="true">
<input type="text" name="textfield" value="">

Using a hidden form value comes in handy for such things as logins, where you have a username and password textbox. If the forms action is to send its values to the same page (ie self referencing) then by using a hidden form value you can monitor whether the user has clicked on the submit button and thus filled in the form.
If it is the first time a user has accessed your page, hasdonelogin will have no value, it will be empty. If they have just submitted your form, hasdonelogin will have a value of true, and in that scenario you don't need to show the login form again with the username and password textfields.

<%
'If the hasdonelogin form value equals nothing the form has not been submitted
If Request.Form("hasdonelogin")="" Then
'make sure the username and password textboxes are displayed
%>
<form name="form1" method="post" action="">
<input type="hidden" name="hasdonelogin" value="true">
<input type="text" name="username" value=""><br>
<input type="text" name="password" value=""><br>
<input name="submit" type="submit" value="submit">
</form>
<%
Else'run this code if hasdonelogin has a value of true
'don't show the username and password textboxes
response.write "You clicked on the form and the hidden value has been sent"
End If
%>

Have a look at the tutorial ASP Password Protect for a more detailed explanation and example.

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software