Work With Web Controls

You can create a text box that is read only by setting the Disabled attribute of the TextBox Web control to True.

Example:

Enter Name: <ASP:TEXTBOX ID="inputName" TEXTMODE="SingleLine" TEXT="" WIDTH="200px" RUNAT="Server" DISABLED="True"/>

You can programmatically hide the text boxes from the user by setting the Visible attribute of the TextBox Web control equal to False.

Example:

Enter Name: <ASP:TEXTBOX ID="inputName" TEXTMODE="SingleLine" TEXT="" WIDTH="200px" RUNAT="Server" VISIBLE="False"/>

You can limit the number of characters that a user can type into a textbox. with the MAXLENGTH attribute.

Example:

Enter Name: <ASP:TEXTBOX ID="inputName" TEXTMODE="SingleLine" TEXT="" WIDTH="200px" RUNAT="Server" MAXLENGTH="40"/>

You can create a multiple line textbox by setting the TEXTMODE attribute to MultiLine.

Example:

Enter Name: <ASP:TEXTBOX ID="inputName" TEXTMODE="MultiLine" TEXT="" WIDTH="200px" RUNAT="Server" MAXLENGTH="40"/>

Create a function called SubmitBtn_Click to check the password.

'—— Save the file and request it from the Web server.

± Type in a name and a correct password.

Create a function called SubmitBtn_Click to check the password.

I Add an if statement to check the password and display the message using the Label Web 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.

—E Click the Submit button.

-■ A message appears notifying you that the password is correct.

QUEST BOOLEAN INPUT

Some Web page form questions that you ask your users require a yes/no or true/false response. For these types of responses, you can use the checkBox Web server control. This control functions similarly to the HTMLinputcheckBox HTML server control.

The CheckBox Web control will reside on a server form on your ASP.NET page. The CheckBox control is created with the <asp: checkbox > tag. You need an id attribute to give the control a name, which is how you reference it in code. As with other Web server controls, set the runat attribute to Server.

Use the text attribute to set what is displayed to users for that check box. To process the check box, you should use the Checked property to see whether it is set to true. If set to true, that means that the user clicked the check box.

You can use multiple check boxes on one Web form. In this case of multiple check boxes, you can use the CheckBoxList Web server control. For most cases, you will create a multi selection check box group dynamically by binding the control to a data source. See page 128 for how controls are data bound.

REQUEST BOOLEAN INPUT

REQUEST BOOLEAN INPUT

D Open the

GenericTemplate.aspx template from the Code Templates directory.

< Type a message to the user.

Q Add a server form to the page.

L-0 Add a Button Web control that calls the SubmitBtn_Click for the onClick event.

—0 Add a Label control for the message.

LH Add a CheckBox Web server control.

D Open the

GenericTemplate.aspx template from the Code Templates directory.

< Type a message to the user.

Q Add a server form to the page.

L-0 Add a Button Web control that calls the SubmitBtn_Click for the onClick event.

—0 Add a Label control for the message.

LH Add a CheckBox Web server control.

Was this article helpful?

0 0

Post a comment