Create A Form Button

You can use a form button to control actions that take place on an HTML form, to submit a form to the Web server, or to reset the contents of the form. You can provide the capability to submit a form by placing a submit button (< input TYPE="submit" >) on the form. To enable the user to reset all controls on a form, you can use the reset button (<input TYPE="reset" >).

If you want to process a server-side HTMLForm, you typically use the HTMLInput control. To ensure that the HTMLInput control sends the form to the server, set the type attribute to Submit. You can write code that will run only when the page is submitted to the server by implementing the OnServerClick event.

You can create a simple login page to test for a static password by adding a couple of HTMLInputText controls on the page. See page 74 for more details. You can create two types of text boxes: one for text and another for a password. After creating these, you can place a <Submit> button and a <Reset> button on the form. You implement both of these buttons using the HTMLInputButton control.

CREATE A FORM BUTTON

CREATE A FORM BUTTON

Q Open the

GenericTemplate.aspx from the Code Templates directory.

< Add a message to the

-0 Add an HTMLInputText control for the name and the password and label them.

□ Add an HTMLSpan control on the page to display the results of the login.

user.

Q Open the

GenericTemplate.aspx from the Code Templates directory.

Add a heading for the page.

< Add a message to the

_Q Add a form to the page with a RUNAT attribute set to "Server".

-0 Add an HTMLInputText control for the name and the password and label them.

LO Add an HTMLInputButton on the page and have it call the SubmitBtn_Click function for the OnServerClick event.

□ Add an HTMLSpan control on the page to display the results of the login.

user.

WORK WITH HTML CONTROLS

For the convenience of your user, you can add a clear button to the page that will clear out the contents of the form. There is an input of type-Reset that reasets the form to original values. This example clears all contents despite the original value.

RESULT:

A Web page that allows the user to click the Clear button to clear the form

Create a SubmitBtn_Click function to check the password.

Use an if statement to check the password and display the message using the HTMLSpan control on the page.

, Save the file and request it from the Web server.

Click the Submit button.

Create a SubmitBtn_Click function to check the password.

Use an if statement to check the password and display the message using the HTMLSpan control on the page.

, Save the file and request it from the Web server.

Note: See pages 20 to 25 for instructions on saving a file to the Web server and then requesting the file using the IIS Admin.

Type in a name and a correct password.

Click the Submit button.

-■ A message appears notifying you if your password is correct.

Note: Try entering an incorrect password.

Was this article helpful?

0 0

Post a comment