İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

Replace + Eval + Routing

hakanizm

0
İyinet Üyesi
Katılım
11 Mayıs 2006
Mesajlar
1,952
Reaction score
1
Konum
Nereye
Merhaba,
Url Routing'de Listview içerisinde
<ahref="<%# Eval("Baslik")%>.aspx"><%# Eval("Baslik")%></a>
yazarak Başlığımı getiriyorum.
Ama ben başlığımın link bölümüne gelirken
İstanbul'da okullar "1" gün tatil edildi.
şeklinde gelmesi yerine
istanbul-da-okullar-1-gun-tatil-edildi
şeklinde gelmesini istiyorum.
Bunu en pratik şekilde nasıl yapabilirim ?
 

tlyyvz

0
İyinet Üyesi
Katılım
5 Aralık 2011
Mesajlar
10
Reaction score
0
public static string cevir(string text)
{
if (string.IsNullOrEmpty(text))
return text;

text = text.Replace(":", string.Empty);
text = text.Replace("/", string.Empty);
text = text.Replace("?", string.Empty);
text = text.Replace("#", string.Empty);
text = text.Replace("[", string.Empty);
text = text.Replace("]", string.Empty);
text = text.Replace("@", string.Empty);
text = text.Replace("*", string.Empty);
text = text.Replace(".", string.Empty);
text = text.Replace(",", string.Empty);
text = text.Replace("\"", string.Empty);
text = text.Replace("&", string.Empty);
text = text.Replace("'", string.Empty);
text = text.Replace(" ", "-");
text = text.Replace("ç", "c");
text = text.Replace("Ç", "C");

text = text.Replace("ğ", "g");
text = text.Replace("Ğ", "G");

text = text.Replace("ı", "i");
text = text.Replace("İ", "i");

text = text.Replace("ö", "o");
text = text.Replace("Ö", "ö");

text = text.Replace("ş", "s");
text = text.Replace("Ş", "S");

text = text.Replace("ü", "u");
text = text.Replace("Ü", "U");

return HttpUtility.UrlEncode(text).Replace("%", string.Empty).ToLowerInvariant();
}

Kullanımı;
<a href="<%# cevir(Eval("Baslik").ToString())%>"><%# Eval("Baslik")%></a>
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Backlink ve Tanıtım Yazısı için iletişime geçmek için Skype Adresimiz: .cid.1580508955483fe5

Üst