Advertisement
deresuroberto

Lab2 DAW

Oct 10th, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 6.56 KB | None | 0 0
  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4.   For more information on how to configure your ASP.NET application, please visit
  5.   http://go.microsoft.com/fwlink/?LinkId=169433
  6.   -->
  7.  
  8.  
  9.  
  10. <configuration>
  11.   <appSettings>
  12.     <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  13.   </appSettings>
  14.     <system.web>
  15.       <compilation debug="true" targetFramework="4.5" />
  16.       <httpRuntime targetFramework="4.5" />
  17.     </system.web>
  18. </configuration>
  19.  
  20.  
  21.  
  22.  
  23. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  24.  
  25. <!DOCTYPE html>
  26.  
  27. <html xmlns="http://www.w3.org/1999/xhtml">
  28. <head runat="server">
  29.     <title></title>
  30.     <style>
  31.         span.validation {
  32.             color:red;
  33.         }
  34.     </style>
  35. </head>
  36. <body>
  37.     <form id="form1" runat="server">
  38.     <div>
  39.         Nume <asp:TextBox ID="nume" runat="server"></asp:TextBox>
  40.         <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Baga nume" ControlToValidate="nume"></asp:RequiredFieldValidator><br /><br />
  41.         Prenume <asp:TextBox ID="prenume" runat="server"></asp:TextBox>
  42.         <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator2" runat="server" ErrorMessage="Baga prenume" ControlToValidate="prenume"></asp:RequiredFieldValidator><br /><br />
  43.         Email <asp:TextBox ID="email" runat="server"></asp:TextBox>
  44.         <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator3" runat="server" ErrorMessage="Baga bine" ControlToValidate="email"></asp:RequiredFieldValidator>
  45.         <asp:RegularExpressionValidator runat="server" CssClass="validation" ErrorMessage="Email incorect" ControlToValidate="email" ValidationExpression="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"></asp:RegularExpressionValidator><br /><br />
  46.         Parola <asp:TextBox ID="parola" runat="server" type="password"></asp:TextBox>
  47.         <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator4" runat="server" ErrorMessage="Baga bine" ControlToValidate="parola"></asp:RequiredFieldValidator><br /><br />
  48.         Confirmare parola <asp:TextBox ID="confirmare" runat="server" type="password"></asp:TextBox>
  49.         <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator5" runat="server" ErrorMessage="Baga bine" ControlToValidate="confirmare"></asp:RequiredFieldValidator>
  50.         <asp:CompareValidator CssClass="validation" ID="CompareValidator1" runat="server" ErrorMessage="Parola diferite!" ControlToValidate="parola" ControlToCompare="confirmare"></asp:CompareValidator><br /><br />
  51.         Facultate <asp:DropDownList ID="facultate" runat="server" ValueToCompare="facultate">
  52.                   <asp:ListItem>Alege</asp:ListItem>
  53.                   <asp:ListItem>UNIBUC</asp:ListItem>
  54.                   <asp:ListItem>ASE</asp:ListItem>
  55.                   <asp:ListItem>Poli</asp:ListItem>
  56.                   </asp:DropDownList>
  57.         <asp:CompareValidator ID="CompareValidator2" runat="server" CssClass="validation" ErrorMessage="Alege facultate!" ControlToValidate="facultate" Operator="NotEqual" ValueToCompare="Alege"></asp:CompareValidator>
  58.         <br /><br />
  59.         Anul <asp:DropDownList ID="an" runat="server">
  60.              <asp:ListItem>Alege</asp:ListItem>
  61.              <asp:ListItem>I</asp:ListItem>
  62.              <asp:ListItem>II</asp:ListItem>
  63.              <asp:ListItem>III</asp:ListItem>
  64.              </asp:DropDownList>
  65.         <asp:CompareValidator ID="CompareValidator3" runat="server" CssClass="validation" ErrorMessage="Alege anul!" ControlToValidate="an" Operator="NotEqual" ValueToCompare="Alege"></asp:CompareValidator>
  66.         <br /><br />
  67.        
  68.         Data nasterii <asp:TextBox ID="data" runat="server" type="datetime"></asp:TextBox>
  69.         <asp:CompareValidator ID="CompareValidator4" runat="server" CssClass="validation" ErrorMessage="Trebuie sa fie data!" ControlToValidate="data" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
  70.         <br /><br />
  71.  
  72.         Sex <asp:RadioButtonList id="sex" runat="server">
  73.             <asp:ListItem id="option1" runat="server" value="M" ></asp:ListItem>
  74.             <asp:ListItem id="option2" runat="server" value="F" ></asp:ListItem>
  75.             </asp:RadioButtonList>
  76.         <br /><br />
  77.  
  78.         Varsta <asp:TextBox ID="varsta" runat="server"></asp:TextBox>
  79.         <asp:RangeValidator ID="RangeValidator1" runat="server" CssClass="validation" ErrorMessage="Varsta invalida!" ControlToValidate="varsta" MaximumValue="120" MinimumValue="0" Type="Integer"></asp:RangeValidator>
  80.         <asp:CustomValidator ID="CustomValidator1" runat="server" CssClass="validation" ErrorMessage="Varsta nu corespunde cu data!" ControlToValidate="varsta" OnServerValidate="VarstaValidate"></asp:CustomValidator>
  81.         <br /><br />
  82.  
  83.         Angajat <asp:CheckBox AutoPostBack="True" Enabled="True" OnCheckedChanged="angajat_CheckedChanged" ID="angajat" runat="server" ValidateRequestMode="Disabled" ViewStateMode="Disabled" />
  84.         <br /><br />
  85.  
  86.         <asp:Panel ID="panel" Visible="false" runat="server">
  87.             Firma <asp:TextBox ID="firma" runat="server"></asp:TextBox> <br /> <br />
  88.             Salariu <asp:TextBox ID="salariu" runat="server"></asp:TextBox> <br /> <br />
  89.         </asp:Panel>
  90.         <br /> <br />
  91.  
  92.         <asp:Button OnClick="submit_Click" ID="submit" runat="server" Text="Submit" /><br /><br />
  93.         <asp:Literal ID="literal" runat="server"></asp:Literal>
  94.     </div>
  95.     </form>
  96. </body>
  97. </html>
  98.  
  99.  
  100.  
  101. using System;
  102. using System.Collections.Generic;
  103. using System.Linq;
  104. using System.Web;
  105. using System.Web.UI;
  106. using System.Web.UI.WebControls;
  107.  
  108. public partial class _Default : System.Web.UI.Page
  109. {
  110.     protected void Page_Load(object sender, EventArgs e)
  111.     {
  112.  
  113.     }
  114.  
  115.     protected void submit_Click(object sender, EventArgs e)
  116.     {
  117.         literal.Text = nume.Text + "  " + prenume.Text + " a fost inregistrat. Email: " + email.Text + " Parola: " + parola.Text + " Facultate: " + facultate.Text + " Anul: " + an.Text + " Data nasterii: " + data.Text + " Sex " + sex.Text + " varsta: " + varsta.Text;  
  118.     }
  119.     protected void angajat_CheckedChanged(object sender, EventArgs e)
  120.     {
  121.         panel.Visible = !panel.Visible;
  122.     }
  123.  
  124.     protected void VarstaValidate(object source, ServerValidateEventArgs args)
  125.     {
  126.         int years = (new DateTime(1, 1, 1) + (DateTime.Now - DateTime.Parse(data.Text))).Year - 1;
  127.  
  128.         if (years == int.Parse(varsta.Text))
  129.             args.IsValid = true;
  130.         else
  131.             args.IsValid = false;
  132.     }
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement