ASP.NET Nedir?
ASP.NET Örnekeri, ASP.NET’in temel ve gelişmiş kavramlarını sağlar. ASP.NET Örnekeri hem yeni başlayanlar hem de profesyoneller için tasarlanmıştır.
ASP.NET, Microsoft tarafından tasarlanmış ve geliştirilmiş bir web çerçevesidir. Web siteleri, web uygulamaları ve web hizmetleri geliştirmek için kullanılır. HTML, CSS ve JavaScript’in harika entegrasyonunu sağlar. İlk olarak Ocak 2002’de piyasaya sürüldü. Ortak Dil Çalışma Zamanı (CLR) üzerine kurulmuştur ve programcıların desteklenen herhangi bir .NET dilini kullanarak kod yazmalarına izin verir.
ASP.NET Eğiticimiz, ASP.Net tanıtımı, özellikler, proje, örnek, sunucu denetimleri, etiketler, metin kutusu, düğme, köprü, radyo düğmesi, takvim, onay kutusu, dosya yükleme, olay işleme, kimlik doğrulama, html sunucu kontrolü, karşılaştırmak geçerli veri, aralık doğrulayıcı, doğrulama özeti, mvc giriş, mvc proje, görünüm, doğrulama, varlık çerçevesi, kimlik doğrulama vb ..
ASP.NET Örnekleri
Örnek:Asp.Net RegularExpressionValidator Kontrolü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dogrulama3.aspx.cs" Inherits="dogrumalama3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } .style3 { width: 132px; } .style4 { width: 607px; } .style5 { width: 117px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table class="style1"> <tr> <td class="style5"> E-Mail Adresiniz</td> <td class="style3"> <asp:TextBox ID="TextBox1" runat="server" Height="24px" MaxLength="200" Width="181px"></asp:TextBox> </td> <td class="style4"> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Lütfen Geçerli Bir E-Mail Giriniz.." ValidationExpression="w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style5"> Web Adresiniz</td> <td class="style3"> <asp:TextBox ID="TextBox2" runat="server" Width="184px"></asp:TextBox> </td> <td class="style4"> <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Lütfen Geçerli Bir Web Adresi Giriniz.." ValidationExpression="http(s)?://([w-]+.)+[w-]+(/[w- ./?%&=]*)?"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style5"> </td> <td class="style3"> <asp:Button ID="Button1" runat="server" Text="GİRİŞ" /> </td> <td class="style4"> </td> </tr> </table> </div> </form> </body> </html> |
Örnek:Asp.Net Dört İşlem
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dort_islem.aspx.cs" Inherits="dort_islem" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 109px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table class="style1"> <tr> <td class="style2"> <asp:Label ID="Label1" runat="server" Font-Size="18pt" ForeColor="#3399FF" Text="1.SAYI"></asp:Label> </td> <td> <asp:TextBox ID="TextBox1" runat="server" Font-Size="18pt" ForeColor="#3399FF"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style2"> <asp:Label ID="Label2" runat="server" Font-Size="18pt" ForeColor="#3399FF" Text="2.SAYI"></asp:Label> </td> <td> <asp:TextBox ID="TextBox2" runat="server" Font-Size="18pt" ForeColor="#3399FF"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style2"> </td> <td> <asp:Button ID="Button1" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button1_Click" Text="+" /> <asp:Button ID="Button2" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button2_Click" Text="-" /> <asp:Button ID="Button3" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button3_Click" Text="*" /> <asp:Button ID="Button4" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button4_Click" Text="/" /> </td> <td> </td> </tr> <tr> <td class="style2"> <asp:Label ID="Label4" runat="server" Font-Size="18pt" ForeColor="#000099" Text="SONUÇ"></asp:Label> </td> <td> <asp:Label ID="Label3" runat="server" Font-Size="18pt" ForeColor="#000099" Text="Label"></asp:Label> </td> <td> </td> </tr> <tr> <td class="style2"> </td> <td> </td> <td> </td> </tr> </table> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class dort_islem : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 + sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button2_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 - sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button3_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 * sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button4_Click(object sender, EventArgs e) { double sayi1, sayi2, sonuc; sayi1 = Convert.ToDouble(TextBox1.Text); sayi2 = Convert.ToDouble(TextBox2.Text); if (sayi2 == 0) { Label3.Text = "Lütfen 0 dan başka bir sayı giriniz..."; } else { sonuc = sayi1 / sayi2; Label3.Text = Convert.ToString(sonuc); } } } |
Örnek:Asp.Net CompareValidator Kontrolü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dogrulama.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 171px; } .style3 { width: 154px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table class="style1"> <tr> <td class="style2"> Şifreyi Giriniz</td> <td class="style3"> <asp:TextBox ID="TextBox1" runat="server" TextMode="Password"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style2"> Şifreyi Tekrar Giriniz:</td> <td class="style3"> <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox> </td> <td> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="Şifre uyuşmazlığı var"></asp:CompareValidator> </td> </tr> </table> </div> </form> </body> </html> |
Örnek: Asp.Net İmage Nesnesi Kullanımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="image.aspx.cs" Inherits="image" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Manzara Resimleri<br /> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Resim 1" /> <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Resim 2" /> <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Resim 3" /> <asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="Resim 4" /> <asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="Resim 5" /> <br /> <asp:Image ID="Image1" runat="server" Height="242px" Width="347px" /> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class image : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/1.jpg"; } protected void Button2_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/2.jpg"; } protected void Button3_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/3.jpg"; } protected void Button4_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/4.jpg"; } protected void Button5_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/5.jpg"; } } |
Örnek: Asp.Net If Else ile Askerlik Kontrolü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AskerlikKontrolu.aspx.cs" Inherits="AspNetOrnekleri.AskerlikKontrolu" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .auto-style4 { width: 218px; height: 31px; } .auto-style9 { width: 181px; } .auto-style10 { width: 218px; } .auto-style11 { width: 181px; height: 31px; } </style> </head> <body> <form id="form1" runat="server"> <table border="0" style="width: 350px"> <tr> <td class="auto-style4">Yaşını Giriniz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style10">Cinsiyeti</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:RadioButton ID="RadioButton1" runat="server" Text="Bay" GroupName="1"/> <asp:RadioButton ID="RadioButton2" runat="server" Text="Bayan" GroupName="1"/> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" Text="Kontrol Et" OnClick="Button1_Click" /> </td> </tr> <tr> <td class="auto-style4">Durumu</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </td> </tr> </table> <div> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing.Design; namespace AspNetOrnekleri { public partial class AskerlikKontrolu : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } int yas=0; protected void Button1_Click(object sender, EventArgs e) { if ((RadioButton1.Checked || RadioButton2.Checked) && (TextBox1.Text !="")) { yas = Convert.ToInt16(TextBox1.Text); if ((RadioButton1.Checked) && (yas > 19) && (yas < 40)) { Label2.ForeColor = System.Drawing.Color.Green; Label2.Text = "Askere Gidebilir"; } else if ((RadioButton1.Checked) && (yas < 20)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Yaşı küçük. Askere Gidemez!"; } else if ((RadioButton2.Checked) && (yas > 19)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Bayan. Askere Gidemez!"; } else if ((RadioButton1.Checked) && (yas > 40)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Yaşı 40'dan Büyük. Askere Gidemez!"; } else { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Askere Gidemez!"; } } else { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Cinsiyetini veya Yaşını Seçiniz"; } } } } |
Örnek:Asp.Net İle Ders Notu Ortalaması Hesaplama
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DersNotu.aspx.cs" Inherits="AspNetOrnekleri.DersNotu" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .tablo { color:red; background-color:aqua; } .auto-style4 { width: 218px; height: 31px; } .auto-style11 { width: 181px; height: 31px; } .auto-style9 { width: 181px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table border="0" style="width: 350px" class="tablo"> <tr> <td class="auto-style4">1.Yazılı Notunuz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4">2.Yazılı Notunuz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4">1.Performans Notunuz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4">2.Performans Notunuz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" Text="Ortalama Hesapla" OnClick="Button1_Click" /> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </td> </tr> </table> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetOrnekleri { public partial class DersNotu : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } int y1, y2, p1, p2, ort; protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "") { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "Lütfen Bilgileri Tam Giriniz."; Label2.Text = ""; } else { y1 = Convert.ToInt16(TextBox1.Text); y2 = Convert.ToInt16(TextBox2.Text); p1 = Convert.ToInt16(TextBox3.Text); p2 = Convert.ToInt16(TextBox4.Text); ort = (y1 + y2 + p1 + p2) / 4; if (y1 < 0 || y1 > 100 || y2 < 0 || y2 > 100 || p2 < 0 || p2 > 100 || p1 < 0 || p1 > 100) { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "Tüm notları 0 ile 100 arasında girin."; Label2.Text = ""; } else if (ort > 49) { Label1.ForeColor = System.Drawing.Color.Green; Label2.ForeColor = System.Drawing.Color.Green; Label1.Text = ort.ToString(); Label2.Text = "Dersten Geçtiniz."; } else { Label1.ForeColor = System.Drawing.Color.Red; Label2.ForeColor = System.Drawing.Color.Red; Label1.Text = ort.ToString(); Label2.Text = "Dersten Kaldınız."; } } } } } |
Örnek: Asp.Net İki Sayı Arasındaki Asal Sayıları Bulma
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IkiSayiArasindakiAsalSayilar.aspx.cs" Inherits="AspNetOrnekleri.IkiSayiArasindakiAsalSayilar" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .tablo { color:red; background-color:lightyellow; } .auto-style4 { width: 218px; height: 31px; } .auto-style11 { width: 181px; height: 31px; } .auto-style9 { width: 181px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table border="0" style="width: 350px" class="tablo"> <tr> <td colspan="2">ASAL SAYILARI BULMA</td> </tr> <tr> <td class="auto-style4">İlk Sayı</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4">Son Sayı</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Asal Olanları Bul" /> </td> </tr> <tr> <td class="auto-style4">İki Sayı Arasında Bulunan Asal Sayılar</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:ListBox ID="ListBox1" runat="server" Height="186px" Width="149px"></asp:ListBox> <br /> </td> </tr> <tr> <td class="auto-style4" colspan="2"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </td> </tr> </table> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetOrnekleri { public partial class IkiSayiArasindakiAsalSayilar : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } int ilksayi, sonsayi; protected void Button1_Click(object sender, EventArgs e) { ListBox1.Items.Clear(); ilksayi = Convert.ToInt32(TextBox1.Text); sonsayi = Convert.ToInt32(TextBox2.Text); int sayi = ilksayi; bool durum = true; while (sayi < sonsayi) { sayi++; for (int i = 2; i < sayi; i++) { if (sayi % i == 0) { durum = false; } } if (durum == true && sayi != 1) { ListBox1.Items.Add(sayi.ToString()); } durum = true; } //www.bilisimkonulari.com Label1.Text = "İki Sayı Arasında " + ListBox1.Items.Count.ToString() + " Tane Asal Sayı Var"; } } } |
Örnek: Asp.Net Tek Sayı Çift Sayı Bulan Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TekSayiCiftSayi.aspx.cs" Inherits="AspNetOrnekleri.TekSayiCiftSayi" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .auto-style4 { width: 218px; height: 31px; } .auto-style11 { width: 181px; height: 31px; } .auto-style9 { width: 181px; } .tablo { color:blue; } </style> <script type="text/javascript"> $(function () { $('#TextBox1').keydown(function (e) { if (e.shiftKey || e.ctrlKey || e.altKey) { e.preventDefault(); } else { var key = e.keyCode; if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) { e.preventDefault(); } } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <table border="0" style="width: 350px" class="tablo"> <tr> <td class="auto-style4">Sayıyı Giriniz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server" onkeypress="SayiGirme"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" Text="Sayıyı İncele" OnClick="Button1_Click" /> </td> </tr> <tr> <td class="auto-style4">Girdiğiniz Sayı</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </td> </tr> </table> </div> </form> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetOrnekleri { public partial class TekSayiCiftSayi : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } double sayi; protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Lütfen bir Sayı Giriniz."; } else { sayi = Convert.ToInt16(TextBox1.Text); if (sayi % 2 == 0) { Label2.ForeColor = System.Drawing.Color.Green; Label2.Text = "Çift Sayıdır."; } else { Label2.ForeColor = System.Drawing.Color.Green; Label2.Text = "Tek Sayıdır."; } } } } } |
Örnek: ASP.NET Not Ortalaması Hesaplama
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="notortalama.aspx.cs" Inherits="WebApplication2.WebForm2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="1.Yazılı"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label2" runat="server" Text="2.Yazılı"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Text="Sözlü"></asp:Label> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Hesapla" /> <br /> <asp:Label ID="Label4" runat="server" Text="Sonuç"></asp:Label> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { int sayi1 = Convert.ToInt16(TextBox1.Text); int sayi2 = Convert.ToInt16(TextBox2.Text); int sayi3 = Convert.ToInt16(TextBox3.Text); int ort = (sayi1 + sayi2 + sayi3) / 3; if (ort < 45) { Label4.Text = "Not Ortalanız= " + ort.ToString() + " Kaldınız!!!!"; } else { Label4.Text = "Not Ortalamanız=" + ort.ToString() + " Geçtiniz ;)"; } } } } |
C#
1 2 3 4 5 6 7 8 9 10 11 | protected void Button1_Click(object sender, EventArgs e) { ListBox2.Items.Add(ListBox1.SelectedItem.Text); } protected void Button2_Click(object sender, EventArgs e) { ListBox2.Items.Remove(ListBox2.SelectedItem.Text); } |
Örnek: ASP.NET radio button kullanımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <div> <h4>Öğrenim Durumu</h4> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>İlkokul</asp:ListItem> <asp:ListItem>Ortaokul</asp:ListItem> <asp:ListItem>Lise</asp:ListItem> <asp:ListItem>Lisans</asp:ListItem> <asp:ListItem>Yüksek Lisans</asp:ListItem> </asp:RadioButtonList> <h4>Medeni Hali </h4> <asp:RadioButton ID="RadioButton1" runat="server" GroupName="medeni" Text="Evli" /> <br /> <asp:RadioButton ID="RadioButton2" runat="server" GroupName="medeni" Text="Bekar" /> <br /> <asp:Button ID="Button1" runat="server" Text="Kaydet" /> </div> <asp:BulletedList ID="BulletedList1" runat="server"> </asp:BulletedList> |
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | protected void Button1_Click(object sender, EventArgs e) { BulletedList1.Items.Clear(); BulletedList1.Items.Add(RadioButtonList1.SelectedValue.ToString()); if (RadioButton1.Checked) { BulletedList1.Items.Add(RadioButton1.Text); } if (RadioButton2.Checked) { BulletedList1.Items.Add(RadioButton2.Text); } } |
Örnek: Checkbox kullanımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <div align="left" style="width: 259px"> <b>Hakim Olduğunuz Konular </b> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BorderStyle="Dotted"> <asp:ListItem>Asp.Net</asp:ListItem> <asp:ListItem>C#</asp:ListItem> <asp:ListItem>Php</asp:ListItem> <asp:ListItem>JavaScript</asp:ListItem> <asp:ListItem>Sql</asp:ListItem> <asp:ListItem>Word</asp:ListItem> <asp:ListItem>Excel</asp:ListItem> <asp:ListItem>PowerPoint</asp:ListItem> </asp:CheckBoxList> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Kaydet" /> <br /> <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" oncheckedchanged="CheckBox1_CheckedChanged" Text="Yatay Göster" /> <br /> <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" oncheckedchanged="CheckBox2_CheckedChanged" Text="Seçenekleri Tablo Halinde Göster" /> <br /> <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" oncheckedchanged="CheckBox3_CheckedChanged" Text="İki Sütünlu Göster" /> </div> <div align="left"> <asp:BulletedList ID="BulletedList1" runat="server"> </asp:BulletedList> </div> </form> |
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i <= CheckBoxList1.Items.Count - 1; i++) { if (CheckBoxList1.Items[i].Selected) { BulletedList1.Items.Add(CheckBoxList1.Items[i].Text); } } } protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { if (CheckBox1.Checked == true) { CheckBoxList1.RepeatDirection = RepeatDirection.Horizontal; } else { CheckBoxList1.RepeatDirection = RepeatDirection.Vertical; } } protected void CheckBox2_CheckedChanged(object sender, EventArgs e) { if (CheckBox2.Checked == true) { CheckBoxList1.RepeatLayout = RepeatLayout.Table; } else { CheckBoxList1.RepeatLayout = RepeatLayout.Flow; } } protected void CheckBox3_CheckedChanged(object sender, EventArgs e) { if (CheckBox3.Checked == true) { CheckBoxList1.RepeatColumns = 2; } else { CheckBoxList1.RepeatColumns = 1; } } |
Örnek: Listbox kullanımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <asp:ListBox ID="ListBox1" runat="server" Height="113px" Width="161px"> <asp:ListItem>Programlama Temelleri</asp:ListItem> <asp:ListItem>Bilişim Tek. Tem.</asp:ListItem> <asp:ListItem>Grafik Animasyon</asp:ListItem> <asp:ListItem>Web Tasarım ve Prog</asp:ListItem> <asp:ListItem>Veritabanı Org.</asp:ListItem> <asp:ListItem>Temel Elktro</asp:ListItem> </asp:ListBox> <asp:Button ID="Button1" runat="server" Text="Ekle" onclick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Çıkar" onclick="Button2_Click" /> <asp:ListBox ID="ListBox2" runat="server" Height="113px" Width="160px"></asp:ListBox> |
Örnek : ASP.NET Dört İşlem Yapımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dort_islem.aspx.cs" Inherits="dort_islem" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 109px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table class="style1"> <tr> <td class="style2"> <asp:Label ID="Label1" runat="server" Font-Size="18pt" ForeColor="#3399FF" Text="1.SAYI"></asp:Label> </td> <td> <asp:TextBox ID="TextBox1" runat="server" Font-Size="18pt" ForeColor="#3399FF"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style2"> <asp:Label ID="Label2" runat="server" Font-Size="18pt" ForeColor="#3399FF" Text="2.SAYI"></asp:Label> </td> <td> <asp:TextBox ID="TextBox2" runat="server" Font-Size="18pt" ForeColor="#3399FF"></asp:TextBox> </td> <td> </td> </tr> <tr> <td class="style2"> </td> <td> <asp:Button ID="Button1" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button1_Click" Text="+" /> <asp:Button ID="Button2" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button2_Click" Text="-" /> <asp:Button ID="Button3" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button3_Click" Text="*" /> <asp:Button ID="Button4" runat="server" Font-Size="18pt" ForeColor="#660033" onclick="Button4_Click" Text="/" /> </td> <td> </td> </tr> <tr> <td class="style2"> <asp:Label ID="Label4" runat="server" Font-Size="18pt" ForeColor="#000099" Text="SONUÇ"></asp:Label> </td> <td> <asp:Label ID="Label3" runat="server" Font-Size="18pt" ForeColor="#000099" Text="Label"></asp:Label> </td> <td> </td> </tr> <tr> <td class="style2"> </td> <td> </td> <td> </td> </tr> </table> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class dort_islem : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 + sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button2_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 - sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button3_Click(object sender, EventArgs e) { int sayi1, sayi2, sonuc; sayi1 = Convert.ToInt32(TextBox1.Text); sayi2 = Convert.ToInt32(TextBox2.Text); sonuc = sayi1 * sayi2; Label3.Text = Convert.ToString(sonuc); } protected void Button4_Click(object sender, EventArgs e) { double sayi1, sayi2, sonuc; sayi1 = Convert.ToDouble(TextBox1.Text); sayi2 = Convert.ToDouble(TextBox2.Text); if (sayi2 == 0) { Label3.Text = "Lütfen 0 dan başka bir sayı giriniz..."; } else { sonuc = sayi1 / sayi2; Label3.Text = Convert.ToString(sonuc); } } } |
Örnek: ASP.NET TextBox Nesnesi Kontrolü
Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TextBox.aspx.cs" Inherits="TextBox" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Adınızı Giriniz <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Yazdır" Width="103px" /> <br /> <br /> <br /> <br /> <asp:Label ID="Label1" runat="server" Font-Size="25pt" ForeColor="#FF3300"></asp:Label> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class TextBox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; } } |
Örnek: Asp.Net Image Nesnesi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="image.aspx.cs" Inherits="image" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Manzara Resimleri<br /> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Resim 1" /> <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Resim 2" /> <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Resim 3" /> <asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="Resim 4" /> <asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="Resim 5" /> <br /> <asp:Image ID="Image1" runat="server" Height="242px" Width="347px" /> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class image : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/1.jpg"; } protected void Button2_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/2.jpg"; } protected void Button3_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/3.jpg"; } protected void Button4_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/4.jpg"; } protected void Button5_Click(object sender, EventArgs e) { Image1.ImageUrl = "resimler/5.jpg"; } } |
Örnek: Asp.NeET If Else ile Askerlik Kontrolü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AskerlikKontrolu.aspx.cs" Inherits="AspNetOrnekleri.AskerlikKontrolu" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .auto-style4 { width: 218px; height: 31px; } .auto-style9 { width: 181px; } .auto-style10 { width: 218px; } .auto-style11 { width: 181px; height: 31px; } </style> </head> <body> <form id="form1" runat="server"> <table border="0" style="width: 350px"> <tr> <td class="auto-style4">Yaşını Giriniz</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style10">Cinsiyeti</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:RadioButton ID="RadioButton1" runat="server" Text="Bay" GroupName="1"/> <asp:RadioButton ID="RadioButton2" runat="server" Text="Bayan" GroupName="1"/> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" Text="Kontrol Et" OnClick="Button1_Click" /> </td> </tr> <tr> <td class="auto-style4">Durumu</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </td> </tr> </table> <div> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing.Design; namespace AspNetOrnekleri { public partial class AskerlikKontrolu : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } int yas=0; protected void Button1_Click(object sender, EventArgs e) { if ((RadioButton1.Checked || RadioButton2.Checked) && (TextBox1.Text !="")) { yas = Convert.ToInt16(TextBox1.Text); if ((RadioButton1.Checked) && (yas > 19) && (yas < 40)) { Label2.ForeColor = System.Drawing.Color.Green; Label2.Text = "Askere Gidebilir"; } else if ((RadioButton1.Checked) && (yas < 20)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Yaşı küçük. Askere Gidemez!"; } else if ((RadioButton2.Checked) && (yas > 19)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Bayan. Askere Gidemez!"; } else if ((RadioButton1.Checked) && (yas > 40)) { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Yaşı 40'dan Büyük. Askere Gidemez!"; } else { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Askere Gidemez!"; } } else { Label2.ForeColor = System.Drawing.Color.Red; Label2.Text = "Cinsiyetini veya Yaşını Seçiniz"; } } } } |
Örnek: Asp.Net İki Sayı Arasındaki Asal Sayıları Bulma
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IkiSayiArasindakiAsalSayilar.aspx.cs" Inherits="AspNetOrnekleri.IkiSayiArasindakiAsalSayilar" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .tablo { color:red; background-color:lightyellow; } .auto-style4 { width: 218px; height: 31px; } .auto-style11 { width: 181px; height: 31px; } .auto-style9 { width: 181px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table border="0" style="width: 350px" class="tablo"> <tr> <td colspan="2">ASAL SAYILARI BULMA</td> </tr> <tr> <td class="auto-style4">İlk Sayı</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4">Son Sayı</td> <td aria-autocomplete="inline" class="auto-style11"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </td> </tr> <tr> <td class="auto-style4"> </td> <td aria-autocomplete="inline" class="auto-style9"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Asal Olanları Bul" /> </td> </tr> <tr> <td class="auto-style4">İki Sayı Arasında Bulunan Asal Sayılar</td> <td aria-autocomplete="inline" class="auto-style9"> <asp:ListBox ID="ListBox1" runat="server" Height="186px" Width="149px"></asp:ListBox> <br /> </td> </tr> <tr> <td class="auto-style4" colspan="2"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </td> </tr> </table> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetOrnekleri { public partial class IkiSayiArasindakiAsalSayilar : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } int ilksayi, sonsayi; protected void Button1_Click(object sender, EventArgs e) { ListBox1.Items.Clear(); ilksayi = Convert.ToInt32(TextBox1.Text); sonsayi = Convert.ToInt32(TextBox2.Text); int sayi = ilksayi; bool durum = true; while (sayi < sonsayi) { sayi++; for (int i = 2; i < sayi; i++) { if (sayi % i == 0) { durum = false; } } if (durum == true && sayi != 1) { ListBox1.Items.Add(sayi.ToString()); } durum = true; } Label1.Text = "İki Sayı Arasında " + ListBox1.Items.Count.ToString() + " Tane Asal Sayı Var"; } } } |
Örnek: ASP.NET Parola Kontrolü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ParolaGirisi.aspx.cs" Inherits="AspNetUygulamalari.ParolaGirisi" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Kullanıcı Adı <asp:TextBox ID="TextBox1" runat="server" ForeColor="#CC0000"></asp:TextBox> <br /> Parola <asp:TextBox ID="TextBox2" runat="server" ForeColor="#CC0000"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" BackColor="Yellow" OnClick="Button1_Click" Text="Giriş" /> <br /> <br /> <asp:Label ID="Label1" runat="server" ForeColor="#6600FF" Text="Label"></asp:Label> </div> </form> </body> </html> |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetUygulamalari { public partial class ParolaGirisi : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string KullaniciAdi, Sifre; KullaniciAdi = TextBox1.Text; Sifre = TextBox2.Text; if (KullaniciAdi == "admin" && Sifre == "pass") { Label1.Text = "Hoş Geldiniz!.."; } else { Label1.Text = "Bilgiler yanlıştır!.."; } } } } |
Örnek: Asp.Net RadioButton Nesnesi Kullanımı
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadioButtonOrnegi.aspx.cs" Inherits="AspNetUygulamalari.RadioButtonOrnegi" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .auto-style1 { height: 29px; } </style> </head> <body> <form id="form1" runat="server"> <div> Asp.Net RadioButton Örneği<br /> <br /> <table> <tr> <td class="auto-style1">Adı </td> <td class="auto-style1"> <asp:TextBox ID="TextBox1" runat="server" BackColor="Yellow"></asp:TextBox> </td> </tr> <tr> <td>Soyadı</td> <td> <asp:TextBox ID="TextBox2" runat="server" BackColor="Yellow"></asp:TextBox> </td> </tr> </table> <br /> <asp:RadioButton ID="RadioButton1" GroupName="cinsiyet" runat="server" Text="Bay" ForeColor="#3366CC" /> <br /> <asp:RadioButton ID="RadioButton2" GroupName="cinsiyet" runat="server" Text="Bayan" ForeColor="#3366CC" /> <br /> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Bilgileri Yazdır" Font-Bold="True" ForeColor="Red" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text="Label" Font-Bold="True" ForeColor="#CC3300"></asp:Label> </div> </form> </body> </html> |
Progra.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspNetUygulamalari { public partial class RadioButtonOrnegi : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string Ad, Soyad; string Cinsiyet = null; Ad = TextBox1.Text; Soyad = TextBox2.Text; if (RadioButton1.Checked == true) { |