ASP.NET: Validation Controls – Controllare l’input dell’utente – Codice sorgente dell’esempio

Sorgenti: RequiredFieldValidator.aspx

Scarica i sorgenti: aspnet06.zip

Articolo a cui si riferisce il codice: ASP.NET: Validation Controls

RequiredFieldValidator.aspx – Prova l’esempio [nuova finestra]

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3 
  4 <%@Page Language="VB"%>
  5 <%@Register TagPrefix="ANet" TagName="Footer" Src="includes/footer.ascx"%>
  6 
  7 
  8 <!
  9 # nome: RequiredFieldValidator.aspx
 10 # scritto da: Antonio Volpon
 11 # data creazione: 25 Ottobre 2001
 12 # ultima modifica: 25 Ottobre 2001
 13 # copyright: Antonio Volpon
 14 >
 15 
 16 <script language="vb" runat="server">
 17 
 18  Sub Button_Click(objSender as object, objArgs as EventArgs)
 19 
 20      If Page.IsValid Then
 21        risposta.InnerText = "Grazie per i tuoi dati."
 22      Else
 23        risposta.InnerText = "Devi compilare correttamente i campi."
 24      End If
 25      
 26  End Sub
 27 
 28 </script>
 29 
 30 
 31 <html>
 32   <head>
 33 
 34     <link rel="stylesheet" href="css/aspnet.css" type="text/css">
 35     </link>
 36     <title>Input Validation Controls: RequiredFieldValidator</title>
 37     
 38   </head>
 39   
 40   <body>
 41     <div class="titolo">
 42       Input Validation Controls: RequiredFieldValidator
 43     </div>
 44     
 45     <hr noshade="noshade" size="1" width="100%" />
 46 
 47     <form runat="server">
 48     <table border="0" align="center">
 49     <tr>
 50       <td align="right">Nome:</td>
 51        <td><input type="text" id="txtNome" size="20" runat="server" /></td>
 52        <td>
 53  <asp:RequiredFieldValidator id="reqNome"
 54  ControlToValidate="txtNome"
 55  Display="Static"
 56  runat="server">

 57        * Campo obbligatorio
 58        </asp:RequiredFieldValidator>
 59       </td>
 60      </tr>
 61     <tr>
 62        <td align="right">Cognome:</td>
 63        <td><input type="text" id="txtCognome" size="20" runat="server" /></td>
 64        <td>
 65  <asp:RequiredFieldValidator id="reqCognome"
 66  ControlToValidate="txtCognome"
 67  Display="Static"
 68  runat="server">

 69            * Campo obbligatorio
 70           </asp:RequiredFieldValidator>
 71        </td>
 72     </tr>
 73     <tr>
 74        <td align="right" colspan="2" align="right">
 75        
 76        <input type="submit"
 77          runat="server"
 78          value="Invia"
 79          onServerClick="Button_Click" />
 80          
 81        </td>
 82        <td>&nbsp;</td>
 83     </tr>
 84     </table>
 85 
 86    </form>
 87   
 88    <div class="risposta" runat="server" id="risposta" EnableViewState="false" />
 89  <ANet:Footer id="Menu" runat="server" />
 90 
 91   </body>
 92 </html>

ASP.NET: Web Form Controls e gli eventi – Codice sorgente dell’esempio

Sorgenti: TextBox.aspx

Scarica i sorgenti: aspnet05.zip

Articolo a cui si riferisce il codice: ASP.NET: Web Form Controls e gli eventi

TextBox.aspx – Prova l’esempio [nuova finestra]

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3 
  4 <%@Page Language="VB"%>
  5 <%@Register TagPrefix="ANet" TagName="Footer" Src="includes/footer.ascx"%>
  6 
  7 <!
  8 # nome: TextBox.aspx
  9 # scritto da: Antonio Volpon
 10 # data creazione: 25 Ottobre 2001
 11 # ultima modifica: 25 Ottobre 2001
 12 # copyright: Antonio Volpon
 13 >
 14 
 15 <script language="vb" runat="server">
 16   sub txtTextBox_Changed(sender as Object, e as EventArgs)
 17     risposta.InnerHtml +="E’ cambiato il valore di " + sender.ID + "<br />"
 18   end sub
 19 </script>
 20 
 21 <html>
 22   <head>
 23     <link rel="stylesheet" href="css/aspnet.css" type="text/css">
 24     </link>
 25     <title>I Web Form Controls: TextBox</title>
 26   </head>
 27   <body>
 28     <div class="titolo">
 29       I Web Form Controls: TextBox
 30     </div>
 31     
 32     <hr noshade="noshade" size="1" width="100%">
 33     
 34     
 35     <form runat="server">
 36     
 37     <table border="1" cellpadding="5" cellspacing="0" bordercolor="#999999" align="center">
 38       <tr>
 39         <td>Primo TextBox</td>
 40         <td>
 41  <asp:TextBox runat="server"
 42  id="txtTextBox1"
 43  Text="Primo TextBox"
 44  BackColor="#99ccff"
 45  TextMode="MultiLine"
 46  Rows="5"
 47  OnTextChanged="txtTextBox_Changed" />

 48         </td>
 49       </tr>
 50       <tr>
 51         <td>Secondo TextBox</td>
 52         <td>
 53  <asp:TextBox runat="server"
 54  id="txtTextBox2"
 55  Text="Secondo TextBox"
 56  TextMode="SingleLine"
 57  AutoPostBack="true"
 58  OnTextChanged="txtTextBox_Changed"/>

 59         </td>
 60       </tr>
 61       <tr>
 62         <td>Terzo TextBox</td>
 63         <td>
 64  <asp:TextBox runat="server"
 65  id="txtTextBox3"
 66  TextMode="Password"/>

 67         </td>
 68       </tr>
 69       <tr>
 70         <td>Quarto TextBox</td>
 71         <td>
 72  <asp:TextBox runat="server"
 73  id="txtTextBox4"
 74  TextMode="MultiLine"
 75  ScrollBars="Both"
 76  Wrap="false"
 77  ReadOnly="true" />

 78         </td>
 79       </tr>
 80       <tr>
 81         <td colspan="2"><input type="submit" value="Invia" alt="invia"></td>
 82       </tr>
 83     </table>
 84     
 85     </form>
 86 
 87  <div id="risposta" class="risposta" runat="server" EnableViewState="false"></div>
 88 
 89  <ANet:Footer id="Menu" runat="server" />
 90     
 91   </body>
 92 </html>

CSS senza lacrime

Joe Gillespie, nel numero di Aprile [nuova finestra] di Web Page Design for Designers, inizia la trattazione di un argomento ormai consolidato, ma che tiene i designer svegli di notte: l’uso efficace dei Css.

Non è sicuramente l’articolo che vi farà capire l’unità di misura da adottare per i font, come creare stili che funzioni in tutti i browser o come correggere i bug di implementazione.

Abbiamo apprezzato più che altro l’introduzione dell’articolo, che permette di capire:

  • perché i Css rimpiazzano alcune inconsistenze dell’Html (come il tag <font>)
  • come far convivere headings (<h1>,<h2>,ecc.) e stili

Nelle prossime puntate Joe promette di entrare nel dettaglio e analizzare i limiti dei browser nel supporto Css.