{"id":89,"date":"2009-07-24T17:38:00","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/www.yazilimmutfagi.com\/?p=89"},"modified":"2009-07-24T17:38:00","modified_gmt":"1970-01-01T00:00:00","slug":"asp-net-validation-kontrolleri-requiredfieldvalidator-ile-bir-alanin-bos-girilmesini-eng","status":"publish","type":"post","link":"https:\/\/www.yazilimmutfagi.com\/index.php\/2009\/07\/24\/asp-net-validation-kontrolleri-requiredfieldvalidator-ile-bir-alanin-bos-girilmesini-eng\/","title":{"rendered":"ASP.NET Validation Kontrolleri \u2013 RequiredFieldValidator ile Bir Alanin Bos Girilmesini Engellemek"},"content":{"rendered":"<p>\n<div style=\"margin: 0cm 0cm 10pt;\"><strong><span style=\"\"><span style=\"font-size: small;\">ASP.NET Validation Kontrolleri &ndash; RequiredFieldValidator<\/span><\/span><\/strong><\/div>\n<div style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\"><span style=\"font-size: 10pt; line-height: 115%;\">Kullanicidan bilgi alirken bazi alanlarin bos ge&ccedil;ilmemesini istedigimiz durumlar olur. &Ouml;rnegin Kullanicini Eposta bilgisini bos birakmasini istemeyiz bu durumda ASP.Net kontollerinden RequiredFieldValidator kontrol&uuml; imdadimiza yetisir. Bir inputun bos olup olmadigimi kontrol etmenin bir &ccedil;ok y&ouml;ntemi vardir. Biz bu makalemizde bunlardan biri olan RequiredFieldValidator kontrol&uuml;n&uuml; inceleyecegiz.<\/span><\/div>\n<div style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\"><span style=\"font-size: 10pt; line-height: 115%;\">Bu kontrol&uuml; Visual Studio&rsquo;da Toolbox i&ccedil;inde Validation men&uuml;s&uuml; altinda bulabilecegimiz bulabilirsiniz.<\/span><\/div>\n<div style=\"margin: 0cm 0cm 10pt;\"><span style=\"font-size: 10pt; line-height: 115%;\">Ilk olarak sayfamizin html b&ouml;l&uuml;m&uuml;ne bir <\/span><span style=\"font-size: 10pt; color: rgb(163, 21, 21); line-height: 115%;\">RequiredFieldValidator<\/span><span style=\"font-size: 10pt; line-height: 115%;\"> ekliyoruz. Daha sonra bu kontrol&uuml;n sayfamizda bulunan hangi inputu kontrol edecegini belirliyoruz. Bunun i&ccedil;in <\/span><span style=\"font-size: 10pt; color: red; line-height: 115%;\">ControlToValidate <\/span><span style=\"font-size: 10pt; line-height: 115%;\">&ouml;zelligini<\/span><span style=\"font-size: 10pt; line-height: 115%;\">kullaniyoruz. Hata olustugu zaman ekranda g&ouml;r&uuml;necek hata mesajini <\/span><span style=\"font-size: 10pt; color: red; line-height: 115%;\">ErrorMessage<\/span><span style=\"font-size: 10pt; line-height: 115%;\"> &ouml;zelligini setleyerek belirliyoruz. <\/span><\/div>\n<div style=\"margin: 0cm 0cm 10pt;\"><a href='www.yazilimmutfagi.com'>.<\/a><\/div>\n<div style=\"margin: 0cm 0cm 10pt;\"><span style=\"font-size: 10pt; line-height: 115%;\">E-Posta bilgisi almak i&ccedil;in kullanacagimiz bir TextBox kontrol&uuml;ne yazilan bilginin bos olup olmadigini kontrol etmek i&ccedil;in yapmamiz gerekenler bu kadar.<\/span><\/div>\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" style=\"background: rgb(242, 242, 242) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; border-collapse: collapse;\">\n    <tbody>\n        <tr>\n            <td width=\"614\" valign=\"top\" style=\"border: 1pt solid black; padding: 0cm 5.4pt; width: 460.6pt; background-color: transparent;\">\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt; color: blue;\">&lt;<\/span><span style=\"font-size: 9pt; color: rgb(163, 21, 21);\">table<\/span><span style=\"font-size: 9pt; color: blue;\">&gt;<\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">tr<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E-Posta :<\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">asp<\/span><span style=\"color: blue;\">:<\/span><span style=\"color: rgb(163, 21, 21);\">TextBox<\/span> <span style=\"color: red;\">ID<\/span><span style=\"color: blue;\">=&quot;EPostaTextBox&quot;<\/span> <span style=\"color: red;\">runat<\/span><span style=\"color: blue;\">=&quot;server&quot;&gt;&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">asp<\/span><span style=\"color: blue;\">:<\/span><span style=\"color: rgb(163, 21, 21);\">TextBox<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">asp<\/span><span style=\"color: blue;\">:<\/span><span style=\"color: rgb(163, 21, 21);\">RequiredFieldValidator<\/span> <span style=\"color: red;\">ID<\/span><span style=\"color: blue;\">=&quot;RequiredFieldValidator1&quot;<\/span> <span style=\"color: red;\">ControlToValidate<\/span><span style=\"color: blue;\">=&quot;EPostaTextBox&quot;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: red;\">runat<\/span><span style=\"color: blue;\">=&quot;server&quot;<\/span> <span style=\"color: red;\">ErrorMessage<\/span><span style=\"color: blue;\">=&quot;EPosta Alani Bos Olamaz&quot;&gt;&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">asp<\/span><span style=\"color: blue;\">:<\/span><span style=\"color: rgb(163, 21, 21);\">RequiredFieldValidator<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">tr<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">tr<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span> <span style=\"color: red;\">colspan<\/span><span style=\"color: blue;\">=&quot;2&quot;<\/span> <span style=\"color: red;\">align<\/span><span style=\"color: blue;\">=&quot;center&quot;&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;<\/span><span style=\"color: rgb(163, 21, 21);\">asp<\/span><span style=\"color: blue;\">:<\/span><span style=\"color: rgb(163, 21, 21);\">Button<\/span> <span style=\"color: red;\">ID<\/span><span style=\"color: blue;\">=&quot;Button1&quot;<\/span> <span style=\"color: red;\">runat<\/span><span style=\"color: blue;\">=&quot;server&quot;<\/span> <span style=\"color: red;\">Text<\/span><span style=\"color: blue;\">=&quot;Onayla&quot;<\/span> <span style=\"color: blue;\">\/&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">td<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt;\">&nbsp;&nbsp;&nbsp; <span style=\"color: blue;\">&lt;\/<\/span><span style=\"color: rgb(163, 21, 21);\">tr<\/span><span style=\"color: blue;\">&gt;<\/span><\/span><\/div>\n            <div style=\"line-height: normal;\"><span style=\"font-size: 9pt; color: blue;\">&lt;\/<\/span><span style=\"font-size: 9pt; color: rgb(163, 21, 21);\">table<\/span><span style=\"font-size: 9pt; color: blue;\">&gt;<\/span><\/div>\n            <\/td>\n        <\/tr>\n    <\/tbody>\n<\/table>\n<div style=\"margin: 0cm 0cm 10pt;\">&nbsp;<\/div>\n<div style=\"margin: 0cm 0cm 10pt;\"><span style=\"font-size: 10pt; line-height: 115%;\">Formdaki Eposta alanini bos biraktigimizda asagidaki gibi bir uyari aliriz.<\/span><\/div>\n<div style=\"margin: 0cm 0cm 10pt;\">&nbsp;<\/div>\n<div style=\"margin: 0cm 0cm 10pt;\"><img decoding=\"async\" loading=\"lazy\" width=\"380\" height=\"70\" alt=\"\" src=\"..\/http:\/\/www.yazilimmutfagi.com\/Makale\/Img\/Sabri\/Requiredfield\/resim1.jpg\" \/><\/div>\n<\/p>","protected":false},"excerpt":{"rendered":"<p>Kullanicidan bilgi alirken bazi alanlarin bos ge&#231;ilmemesini istedigimiz durumlar olur. &#214;rnegin Kullanicini Eposta bilgisini bos birakmasini istemeyiz bu durumda ASP.Net kontollerinden RequiredFieldValidator kontrol&#252; imdadimiza yetisir. Bir inputun bos olup olmadigimi kontrol etmenin bir &#231;ok y&#246;ntemi <\/p>\n","protected":false},"author":517,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[407],"tags":[4285,5039,5782,4290,5225,5640],"_links":{"self":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/89"}],"collection":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/users\/517"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":0,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}