Asp.net ile breadcumbs yapımı
27 Ocak 2021 / 11:50
Burak
Merhabalar,
Asp.net breadcumb kullanmak isterseniz aşağıdaki kodları kullanabilirsiniz.
Css
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 |
<style> .breadcumb div:last-child::after{ content: ""; } .breadcumb div{ font-size: 13px; color: #434650; float:right; } .breadcumb div::after{ content:'/'; padding-left: 5px; padding-right: 5px; } .breadcumb { text-align: left; display: flex; margin-bottom: 17px; } </style> |
Html tarafı
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 |
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style> .bread{ float: right; } .bread::after{ content:'/'; } .breadcumbs { text-align: left; display: inline-block; } </style> </head> <body> <form id="form1" runat="server"> <div class="breadcumbs"> <asp:Literal ID="breadcumb_lt" runat="server"></asp:Literal> </div> </form> </body> </html> |
Codebehind tarafı
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 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using MySql.Data.MySqlClient; using System.Web.Configuration; public partial class test : System.Web.UI.Page { string bag = WebConfigurationManager.ConnectionStrings["dbbaglantisi"].ConnectionString; MySqlConnection baglanti; public string breadcumb_func(string id) { string sonuc = "0"; using (baglanti = new MySqlConnection(bag)) { baglanti.Open(); using (MySqlCommand t = new MySqlCommand("select ad,id,isapi,uid from eticaret_kategoriler where id=?id", baglanti)) { t.Parameters.Add("id", id); using (MySqlDataReader a = t.ExecuteReader()) { while (a.Read()) { breadcumb_lt.Text += "<div class='bread'>"+a["ad"].ToString()+"</div>"; sonuc=a["id"].ToString(); breadcumb_func(a["uid"].ToString()); } a.Close(); a.Dispose(); } } baglanti.Close(); baglanti.Dispose(); } return sonuc; } protected void Page_Load(object sender, EventArgs e) { using(baglanti=new MySqlConnection(bag)) { baglanti.Open(); using (MySqlCommand t = new MySqlCommand("select kid from eticaret_urunler where id='398428'", baglanti)) { using(MySqlDataReader a=t.ExecuteReader()) { while(a.Read()) { breadcumb_func(a["kid"].ToString()); } a.Close(); a.Dispose(); } } baglanti.Close(); baglanti.Dispose(); } } } |
Database yapısı
Bu Yazılarıda Okuyabilirsiniz...
Bir cevap yazın