Tutorial ASP 6

1. bukalah visual studio anda - new project - c# dan buatlah project seperti ini :



2. lalu copy kan script berikut : "TUGAS"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TUGAS.aspx.cs" Inherits="Bab3_LatihanASP6.TUGAS" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>TUGAS ASP6</title>
    <link href="Khania.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .auto-style3 {
            width: 160px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="1" class="dobol">
            <tr>
                <td rowspan="11" class="header"><img width="170px" height="170px" src="logotelkom.jpg" /></td>
                <td colspan="4" class="back"><b>INPUT BIODATA</b></td>
            </tr>
            <tr>
                <td colspan="4"><asp:ValidationSummary ID="vsSumm" CssClass="div" runat="server" Width="250px" ShowMessageBox="true" /></td>
            </tr>
             <tr>
                <td class="auto-style4">Nama Lengkap :</td>
                <td class="auto-style5">
                    <asp:TextBox ID="txtNama" runat="server" Width="165px" Height="30px"></asp:TextBox></td>
                <td class="auto-style4">&nbsp;<asp:RequiredFieldValidator ID="rfvNama" runat="server" ControlToValidate="txtNama"
                    CssClass="RequiredFieldValidator" ErrorMessage="Nama harus diisi.."
                    Text="<img src='errorIcon.png' width='25px' class='center' />Nama Harus Diisi.." />
                    </td>
            </tr>
            <tr>
                <td class="auto-style1">NIS :</td>
                <td class="auto-style3">
                    <asp:TextBox ID="txtNIS" runat="server" Width="165px" Height="30px"></asp:TextBox></td>
                <td class="auto-style4">&nbsp;<asp:RequiredFieldValidator ID="rfvNis" runat="server" ControlToValidate="txtNis"
                    CssClass="RequiredFieldValidator" ErrorMessage="NIS harus diisi.."
                    Text="<img src='errorIcon.png' width='25px' class='center' />NIS Harus Diisi.." />
                    </td>
            </tr>
            <tr>
                <td class="auto-style1">Umur :</td>
                <td class="auto-style3">
                <asp:TextBox ID="txtUmur" runat="server" Width="165px" Height="30px"></asp:TextBox>
            </td>
            <td>&nbsp;<asp:RangeValidator ID="RangeValidator1" ControlToValidate="txtUmur" CssClass="RequiredFieldValidator" runat="server" ErrorMessage="Range Umur 4-99 tahun" MinimumValue="4" MaximumValue="99" Type="Integer" Text="<img src='errorIcon.png' width='25'  class='center'/>Range Umur 4-99 tahun" /></td>
        </tr>
            <tr>
                <td class="auto-style1">Email :</td>
                <td class="auto-style3">
                    <asp:TextBox ID="txtEmail" runat="server" Width="165px" Height="30px"></asp:TextBox></td>
                 <td class="auto-style4">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmail"
                    CssClass="RequiredFieldValidator" ErrorMessage="Email harus diisi.."
                    Text="<img src='errorIcon.png' width='25px' class='center' />Email Harus Diisi.." />
                    </td>
            </tr>
            <tr>
                <td class="auto-style1">Password :</td>
                <td class="auto-style3">
                    <asp:TextBox ID="txtPass" runat="server" Width="165px" Height="30px"></asp:TextBox>
                </td>
                 <td class="auto-style4">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtPass"
                    CssClass="RequiredFieldValidator" ErrorMessage="Password harus diisi.."
                    Text="<img src='errorIcon.png' width='25px' class='center' />Password Harus Diisi.." />
                    </td>
            </tr>
            <tr>
                <td class="auto-style1">Confirm Password :</td>
                <td class="auto-style3">
                    <asp:TextBox ID="txtConfirm" runat="server" Width="165px" Height="30px"></asp:TextBox>
                </td>
                <td class="auto-style4">&nbsp;<asp:CompareValidator ID="cvPass" runat="server" ControlToCompare="txtConfirm" ControlToValidate="txtPass" ErrorMessage="Password dan Confirm harus sama yaaaa!!"
                    Text="<img src='errorIcon.png' width='25px' class='center' />Password dan Confirm harus sama"></asp:CompareValidator>
                    </td>
            </tr>
            <tr>
                <td colspan="4">
                   <div class="tengah"><asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" PostBackUrl="~/Tugas/TugasResult.aspx"/></div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

3. "TugasResult"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TugasResult.aspx.cs" Inherits="Bab3_LatihanASP6.Tugas.TugasResult" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table align="center">
        <tr>
            <td>
            <asp:Label ID="Label1" runat="server" Text="Berikut Data Anda"></asp:Label>
            </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="lblNama" runat="server"></asp:Label><br />
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="lblNIS" runat="server"></asp:Label><br />
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="lblUmur" runat="server"></asp:Label><br />
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="lblEmail" runat="server"></asp:Label><br />
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="lblPassword" runat="server"></asp:Label><br />
        </td>
        </tr>
        </table>
    </div>
    </form>
</body>
</html>

4. "ComparePass"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ComparePass.aspx.cs" Inherits="Bab3_LatihanASP6.ComparePass" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Compare Pass</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Password :
      <asp:TextBox ID="txtPass" TextMode="Password" runat="server"/><br />
        Confirm&nbsp;&nbsp;&nbsp; :
        <asp:TextBox ID="txtRepass" TextMode="Password" runat="server"/><br />
        <asp:CompareValidator ID="cvPass" runat="server" ErrorMessage="<img src='errorIcon.png' width='15' height='15'/><font color=red /> Password dan Confirm harus sama" ControlToValidate="txtPass" ControlToCompare="txtRepass"></asp:CompareValidator>
    </div>
    </form>
</body>
</html>

5. "CompareType"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CompareType.aspx.cs" Inherits="Bab3_LatihanASP6.CompareType" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Compare Data Type</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Masukkan Nilai Raport Anda
        <asp:TextBox ID="txtRaport" runat="server" />
        <asp:CompareValidator ID="cvRaport" runat="server" ErrorMessage="<b><i>{Tipe data harus Pacahan (0,0)}</i></b>" ControlToValidate="txtRaport" Operator="DataTypeCheck" Type="Double" /><br />
    Masukkan Jumlah Saudara Kandung Anda :
        <asp:TextBox ID="txtSaudara" runat="server" />
        <asp:CompareValidator ID="cvSaudara" runat="server" ErrorMessage="<b><i>{Tipe data harus Bilangan Bulat}</i></b>" ControlToValidate="txtSaudara" Operator="DataTypeCheck" Type="Integer" /><br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
    </div>
    </form>
</body>
</html>

6. "CustomNIS"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomNIS.aspx.cs" Inherits="Bab3_LatihanASP6.CustomNIS" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Custom Validate</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Masukkan NIS Anda : <asp:TextBox ID="txtNIS" runat="server"/>
        <asp:CustomValidator ID="cvNIS" runat="server" ErrorMessage="<b>NIS harus 13 Huruf dan Angka</b>" ControlToValidate="txtNis" OnServerValidate="CekNis_ServerVal" /><br />
        <asp:Button ID="btnSubmit" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>

7. MyStyle.css

body {
    text-align: center;
    vertical-align: central;
}

.div {
    margin: 0px auto;
    text-align: left;
    padding: 15px;
    border: 1px dashed #333;
    background-color: #ffd800;
}

table {
    color: #333;
    font-family: Helvetica, Arial, sans-serif;
    width: 510px;
    border-collapse: collapse;
    border-spacing: 0;
    margin-right: 49px;
    text-align: left;
}

td, th {
    border: 1px solid #CCC;
    height: 30px;
    transition: all 0.3s;
}

th {
    background: #F3F3F3;
    font-weight: bold;
    text-align: center;
}

td {
    background: #FAFAFA;
    vertical-align: central;
}

.td {
    text-align: center;
}

tr td:hover {
    background: #666;
    color: #FFF;
}

TEXTAREA, INPUT[type="text"] {
    font-family: Tahoma, Arial, sans-serif;
    font-size: 14px;
    color: #808080;
    padding: 3px;
    background: #EEEfff;
    border-left: solid 1px #c1c1c1;
    border-top: solid 1px #cfcfcf;
    border-right: solid 1px #cfcfcf;
    border-bottom: solid 1px #6f6f6f;
}

    INPUT[type="text"]:focus, INPUT[type="text"]:active {
        border-color: #646464;
        background-color: #ffcf03;
    }

.rfv {
    color: red;
}

    .rfv:hover {
        color: white;
    }

.center {
    vertical-align: top;
}


8. Prasem.css

body {
    text-align: center;
    vertical-align: central;
}

.dobol {
    margin: 100px 0 0 100px;
}
.div {
    margin: 0px auto;
    text-align: left;
    padding: 15px;
    border: 1px dashed #333;
    background-color: #ffd800;
}

table {
    color: #333;
    font-family: Helvetica, Arial, sans-serif;
    width: 650px;
    border-collapse: collapse;
    border-spacing: 0;
    margin-right: 30px;
    text-align: left;
    background-color:antiquewhite;
}

td, th {
    border: 1px solid #CCC;
    height: 30px;
    transition: all 0.3s;
}

th {
    background: #ea0b0b;
    font-weight: bold;
    text-align: center;
}

td {
    background: #FAFAFA;
    vertical-align: central;
}

.td {
    text-align: center;
}

tr td:hover {
    background: #666;
    color: #FFF;
}

TEXTAREA, INPUT[type="text"] {
    font-family: Tahoma, Arial, sans-serif;
    font-size: 14px;
    color: #808080;
    padding: 3px;
    background: #EEEfff;
    border-left: solid 1px #c1c1c1;
    border-top: solid 1px #cfcfcf;
    border-right: solid 1px #cfcfcf;
    border-bottom: solid 1px #6f6f6f;
}

    INPUT[type="text"]:focus, INPUT[type="text"]:active {
        border-color: #646464;
        background-color: #ffcf03;
    }

.rfv {
    color: red;
}

    .rfv:hover {
        color: white;
    }

.center {
    vertical-align: top;
}

        body {
            background-color:cadetblue;
        }
        .tengah {
            text-align:center;
        }
        .k {
            background-color:lightpink;
            border-bottom-left-radius:15px;
            border-top-right-radius:15px;
            border-color:black;
            padding:10px 20px 10px 20px;
            text-align:center;
        }
        .auto-style1 {
            width: 21px;
            text-align:center;
        }
        .header {
            width: 94px;
            text-align: center;
        }
        .back {
            background-color: lime;
            text-shadow:5px 2px 2px #333;
            text-align: center;
            height: 49px;
        }

9. "RangeValidator"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RangeValidator.aspx.cs" Inherits="Bab3_LatihanASP6.RangeValidator" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Range Validator</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Umur : <asp:TextBox ID="txtUmur" runat="server"></asp:TextBox>
        <asp:RangeValidator ID="rvUmur" ControlToValidate="txtUmur" runat="server" ErrorMessage="<font color=red>{Umurnya bos salah}</font>" MinimumValue="4" MaximumValue="99" Type="Integer" />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>

10. "RegexEmail"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RegexEmail.aspx.cs" Inherits="Bab3_LatihanASP6.RegexEmail" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Regex Email</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Masukkan Alamat Email Anda :
        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="reEmail" runat="server" ErrorMessage="<b>{Format email salah}</b>" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-,]\w+)*\.\w+([-,]\w+)*" />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>

11. "RequireImage"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequireImage.aspx.cs" Inherits="Bab3_LatihanASP6.RequireImage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Require Image</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Username : <asp:TextBox ID="txtUser" runat="server"/>
        <asp:RequiredFieldValidator ID="valUser" runat="server" ControlToValidate="txtUser" Text="<img src='errorIcon.png' width='15' height='15' alt='Username diisi ya!!!' />" /><br />
    Password : <asp:TextBox ID="txtPass" runat="server" />
        <asp:RequiredFieldValidator ID="valPass" runat="server" ControlToValidate="txtPass" Text="<img src='errorIcon.png' width='15' height='15' alt='Password juga diisi ya!!!' />" /><br />
        <asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" OnClick="btnSubmit_Click" /><hr />
        <asp:Label ID="lblResult" runat="server"/>
    </div>
    </form>
</body>
</html>

12. "RequireValidator"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequireValidator.aspx.cs" Inherits="Bab3_LatihanASP6.RequireValidator" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Username : <asp:TextBox ID="txtUser" runat="server" /><font color="red">
        <asp:RequiredFieldValidator ID="rfvUser" runat="server" ControlToValidate="txtUser" ErrorMessage="Username nya diisi ya!!!" /></font><br />
        Password : <asp:TextBox ID="txtPass" TextMode="Password" runat="server" /><font color="red">
        <asp:RequiredFieldValidator ID="rfvPass" runat="server" ControlToValidate="txtPass" ErrorMessage="Passwordnya juga yaaa!!" /></font><br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /><hr />
        <asp:Label ID="lblResult" runat="server" />
    </div>
    </form>
</body>
</html>

13. "ValSummary"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValSummary.aspx.cs" Inherits="Bab3_LatihanASP6.ValSummary" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Validation Summary</title>
    <link href="MyStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .auto-style3 {
            width: 160px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ValidationSummary ID="vsSumm" CssClass="div" runat="server" Width="286px" ShowMessageBox="true" />
    </div><br />
    <table style=""width: 100%;">
        <tr><th colspan="3">INPUT DATA DIRI</th></tr>
        <tr>
            <td class="auto-style3">Username :</td>
            <td class="auto-style3">
                <asp:TextBox ID="txtUser" runat="server" Width="165px" Height="30px"></asp:TextBox></td>
            <td>&nbsp;<asp:RequiredFieldValidator ID="rfvUser" ControlToValidate="txtUser" CssClass="RequiredFieldValidator" runat="server" ErrorMessage="Username harus diisi yaa!!" Text="<img src='errorIcon.png' width='15' height='15' class='center'/>Username harus diisi yaa!!" /></td>
        </tr>
        <tr>
            <td class="auto-style1">Password :</td>
            <td class="auto-style3">
                <asp:TextBox ID="txtPass" runat="server" Width="165px" Height="30px"></asp:TextBox>
            </td>
            <td>&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtPass" CssClass="RequiredFieldValidator" runat="server" ErrorMessage="Password diisi juga yaa!!" Text="<img src='errorIcon.png' width='15' height='15' class='center'/>Password harus diisi yaa!!" /></td>
        </tr>
        <tr>
        <td class="auto-style1">Umur :</td>
            <td class="auto-style3">
                <asp:TextBox ID="txtUmur" runat="server" Width="165px" Height="30px"></asp:TextBox>
            </td>
            <td>&nbsp;<asp:RangeValidator ID="RangeValidator1" ControlToValidate="txtUmur" CssClass="RequiredFieldValidator" runat="server" ErrorMessage="Range Umur 4-99 tahun" MinimumValue="4" MaximumValue="99" Type="Integer" Text="<img src='errorIcon.png' width='15' height='15' class='center'/>Range Umur 4-99 tahun" /></td>
        </tr>
    </table>
    <br />
        <asp:Button ID="KIRIM" runat="server" Text="Button" Height="36px" Width="145px" />
</form>
</body>
</html>


14. lalu jalankan program dengan menekan CTRL + F5 dan isi formulirnya :)






Tidak ada komentar:

Posting Komentar