HTML Forms ADO NET Introduction 2002 by Jerry
HTML Forms ADO. NET Introduction © 2002 by Jerry Post 1
Forms to Submit Data 2
Sample Form Code <html> <head><title>Simple Form</title></head> <body> <form method=“post” action=“Handle. Form. aspx”> <p>Name: <input type=“text” name=“Last. Name” /></p> <p>Age: <input type=“text” name=“Age” value=“ 18” /></p> <p><input type=“submit” name=“submit” value=“Submit” /></p> </form> </body> </html> 3
Typically use Tables <html><head><title>Simple Form</title></head> <body> <form method=“post” action=“Handle. Form. aspx”> <table> <tr> <td>Name: </td> <td><input type=“text” name=“Last. Name” /></td> </tr> <td>Age: </td> <td><input type=“text” name=“Age” value=“ 18” /></td> </tr> <td colspan=“ 2”> <input type=“submit” name=“submit” value=“Submit” /></td> </tr> </table> </form> </body></html> 4
Form with Table Layout 5
Form: Method Ø Method: How data is transferred to the server. v Get: method=“get” q Data is transferred on the URL line. q Limited number of characters (as low as 128). q Directly visible to user and easy to alter. v Post: method=“post” q Best to use for most forms. q Data can still be altered by user but only by changing the form. Ø All data is transferred in pairs. v Name=value v Example: Last. Name=Smith 6
Method: Get Data Server file does not exist yet. 7
Input Options <input type=“text” /> Standard text <input type=“password” /> Display **** for text <input type=“hidden” /> In source, but not displayed. <input type=“checkbox” /> Multiple select items. <input type=“radio” /> Single select item. <input type=“submit” /> Standard submit button. <input type=“button” /> Button used with code. 8
Checkboxes and Radio Buttons 9
Checkbox and Radio Group Source <tr> <td>Toppings <input type="checkbox" name="Onions" /> Onions <input type="checkbox" name=“Mushrooms" /> Mushrooms <input type="checkbox" name=“Anchovies" /> Dead fish </td> <td>Crust <input type="radio" name="crust" value="1" /> Thin <input type="radio" name="crust" /> Traditional <input type="radio" name="crust" /> Deep dish </td> </tr> Must be the same name! 10
- Slides: 10