Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <!--
- For more information on how to configure your ASP.NET application, please visit
- http://go.microsoft.com/fwlink/?LinkId=169433
- -->
- <configuration>
- <appSettings>
- <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
- </appSettings>
- <system.web>
- <compilation debug="true" targetFramework="4.5" />
- <httpRuntime targetFramework="4.5" />
- </system.web>
- </configuration>
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <style>
- span.validation {
- color:red;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- Nume <asp:TextBox ID="nume" runat="server"></asp:TextBox>
- <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Baga nume" ControlToValidate="nume"></asp:RequiredFieldValidator><br /><br />
- Prenume <asp:TextBox ID="prenume" runat="server"></asp:TextBox>
- <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator2" runat="server" ErrorMessage="Baga prenume" ControlToValidate="prenume"></asp:RequiredFieldValidator><br /><br />
- Email <asp:TextBox ID="email" runat="server"></asp:TextBox>
- <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator3" runat="server" ErrorMessage="Baga bine" ControlToValidate="email"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator runat="server" CssClass="validation" ErrorMessage="Email incorect" ControlToValidate="email" ValidationExpression="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"></asp:RegularExpressionValidator><br /><br />
- Parola <asp:TextBox ID="parola" runat="server" type="password"></asp:TextBox>
- <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator4" runat="server" ErrorMessage="Baga bine" ControlToValidate="parola"></asp:RequiredFieldValidator><br /><br />
- Confirmare parola <asp:TextBox ID="confirmare" runat="server" type="password"></asp:TextBox>
- <asp:RequiredFieldValidator CssClass="validation" ID="RequiredFieldValidator5" runat="server" ErrorMessage="Baga bine" ControlToValidate="confirmare"></asp:RequiredFieldValidator>
- <asp:CompareValidator CssClass="validation" ID="CompareValidator1" runat="server" ErrorMessage="Parola diferite!" ControlToValidate="parola" ControlToCompare="confirmare"></asp:CompareValidator><br /><br />
- Facultate <asp:DropDownList ID="facultate" runat="server" ValueToCompare="facultate">
- <asp:ListItem>Alege</asp:ListItem>
- <asp:ListItem>UNIBUC</asp:ListItem>
- <asp:ListItem>ASE</asp:ListItem>
- <asp:ListItem>Poli</asp:ListItem>
- </asp:DropDownList>
- <asp:CompareValidator ID="CompareValidator2" runat="server" CssClass="validation" ErrorMessage="Alege facultate!" ControlToValidate="facultate" Operator="NotEqual" ValueToCompare="Alege"></asp:CompareValidator>
- <br /><br />
- Anul <asp:DropDownList ID="an" runat="server">
- <asp:ListItem>Alege</asp:ListItem>
- <asp:ListItem>I</asp:ListItem>
- <asp:ListItem>II</asp:ListItem>
- <asp:ListItem>III</asp:ListItem>
- </asp:DropDownList>
- <asp:CompareValidator ID="CompareValidator3" runat="server" CssClass="validation" ErrorMessage="Alege anul!" ControlToValidate="an" Operator="NotEqual" ValueToCompare="Alege"></asp:CompareValidator>
- <br /><br />
- Data nasterii <asp:TextBox ID="data" runat="server" type="datetime"></asp:TextBox>
- <asp:CompareValidator ID="CompareValidator4" runat="server" CssClass="validation" ErrorMessage="Trebuie sa fie data!" ControlToValidate="data" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
- <br /><br />
- Sex <asp:RadioButtonList id="sex" runat="server">
- <asp:ListItem id="option1" runat="server" value="M" ></asp:ListItem>
- <asp:ListItem id="option2" runat="server" value="F" ></asp:ListItem>
- </asp:RadioButtonList>
- <br /><br />
- Varsta <asp:TextBox ID="varsta" runat="server"></asp:TextBox>
- <asp:RangeValidator ID="RangeValidator1" runat="server" CssClass="validation" ErrorMessage="Varsta invalida!" ControlToValidate="varsta" MaximumValue="120" MinimumValue="0" Type="Integer"></asp:RangeValidator>
- <asp:CustomValidator ID="CustomValidator1" runat="server" CssClass="validation" ErrorMessage="Varsta nu corespunde cu data!" ControlToValidate="varsta" OnServerValidate="VarstaValidate"></asp:CustomValidator>
- <br /><br />
- Angajat <asp:CheckBox AutoPostBack="True" Enabled="True" OnCheckedChanged="angajat_CheckedChanged" ID="angajat" runat="server" ValidateRequestMode="Disabled" ViewStateMode="Disabled" />
- <br /><br />
- <asp:Panel ID="panel" Visible="false" runat="server">
- Firma <asp:TextBox ID="firma" runat="server"></asp:TextBox> <br /> <br />
- Salariu <asp:TextBox ID="salariu" runat="server"></asp:TextBox> <br /> <br />
- </asp:Panel>
- <br /> <br />
- <asp:Button OnClick="submit_Click" ID="submit" runat="server" Text="Submit" /><br /><br />
- <asp:Literal ID="literal" runat="server"></asp:Literal>
- </div>
- </form>
- </body>
- </html>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void submit_Click(object sender, EventArgs e)
- {
- 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;
- }
- protected void angajat_CheckedChanged(object sender, EventArgs e)
- {
- panel.Visible = !panel.Visible;
- }
- protected void VarstaValidate(object source, ServerValidateEventArgs args)
- {
- int years = (new DateTime(1, 1, 1) + (DateTime.Now - DateTime.Parse(data.Text))).Year - 1;
- if (years == int.Parse(varsta.Text))
- args.IsValid = true;
- else
- args.IsValid = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement