Merhaba arkadaşlar vs da kod yazarken lazım olabiliyor tüm satırları collapsed yani kapatmak veya açmak için aşağıdaki kısa yolları kullanabilirsiniz.
1 2 3 4 5 6 7 8 9 |
CTRL + M + O will collapse all. CTRL + M + L will expand all. (in VS 2013 - Toggle All outlining) CTRL + M + P will expand all and disable outlining. CTRL + M + M will collapse/expand the current section. CTRL + M + A will collapse all even in Html files. |
Merhabalar, Asp.net veya C# da ftp ile upload yapmak isterseniz aşağıdaki kod blogunu kullanabilirsiniz.
1 2 3 4 5 6 7 8 9 10 11 |
System.Net.FtpWebRequest rq = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create("ftp url"); rq.Credentials = new System.Net.NetworkCredential("ftp kad", "ftp şifre"); rq.Method = System.Net.WebRequestMethods.Ftp.UploadFile; System.IO.Stream fs = k_resim.PostedFile.InputStream; byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); System.IO.Stream ftpstream = rq.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); ftpstream.Dispose(); |
Merhabalar, Google veya diğer arama motorları için dinamik sitemap hazırlamak için aşağıdaki kodları kullanabilirsiniz.
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 |
protected void Page_Load(object sender, EventArgs e) { Response.Clear(); Response.ContentType = "text/xml"; XmlTextWriter xr = new XmlTextWriter(Response.OutputStream, Encoding.UTF8); xr.WriteStartDocument(); xr.WriteStartElement("urlset"); xr.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"); xr.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); xr.WriteAttributeString("xsi:schemaLocation","http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"); xr.WriteStartElement("url"); xr.WriteElementString("loc", "kök site adresi"); xr.WriteElementString("lastmod", DateTime.Now.ToString("yyyy-MM-dd")); xr.WriteElementString("changefreq", "daily"); xr.WriteElementString("priority", "1"); xr.WriteEndElement(); using (baglanti = new MySqlConnection(bag)) { baglanti.Open(); MySqlCommand t = new MySqlCommand("sql sorgusu", baglanti); MySqlDataReader a = t.ExecuteReader(); while (a.Read()) { xr.WriteStartElement("url"); xr.WriteElementString("loc", "alt detay sayfa linki"); xr.WriteElementString("lastmod", "sayfa güncellenme tarihi"); xr.WriteElementString("priority", "0.5"); xr.WriteElementString("changefreq", "monthly"); xr.WriteEndElement(); } baglanti.Close(); baglanti.Dispose(); } xr.WriteEndDocument(); xr.Flush(); xr.Close(); Response.End(); } |
Burada alıntı yok çünkü bu yazı korumalı.
Burada alıntı yok çünkü bu yazı korumalı.
Merhaba arkadaşlar, bugünkü kod kırıntılarında sizlere dinamik olarak thumbnail oluşturma kod pıtırcıklarını paylaşıcam.Kodlarla uğraşmak istemeyen direk burdan çekebilir kodlar ( hadi gene iyisiniz millet gibi uğraştırmıyorum sizi 🙂 ) Yok illa ben kodları görücem diyorsanız kaputun altı aşağıdaki gibidir. Dosya isminin thumbnail.aspx olduğunu varsayarsak
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; using System.Drawing.Imaging; public partial class thumbnail : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string Image = Request.QueryString["Image"]; if (Image == null) { this.ErrorResult(); return; } string sSize = Request["Size"]; int Size = 120; if (sSize != null) Size = Int32.Parse(sSize); string Path = Server.MapPath(Request.ApplicationPath) + "\\" + Image; Bitmap bmp = CreateThumbnails(Path, Size, Size); if (bmp == null) { this.ErrorResult(); return; } string OutputFilename = null; OutputFilename = Request.QueryString["OutputFilename"]; if (OutputFilename != null) { if (this.User.Identity.Name == "") { // *** Custom error display here bmp.Dispose(); this.ErrorResult(); } try { bmp.Save(OutputFilename); } catch (Exception ex) { bmp.Dispose(); this.ErrorResult(); return; } } // Put user code to initialize the page here Response.ContentType = "image/jpeg"; bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); bmp.Dispose(); } private void ErrorResult() { Response.Clear(); Response.StatusCode = 404; Response.End(); } /// /// Creates a resized bitmap from an existing image on disk. /// Call Dispose on the returned Bitmap object /// /// /// /// /// Bitmap or null public static Bitmap CreateThumbnails(string lcFilename, int lnWidth, int lnHeight) { System.Drawing.Bitmap bmpOut = null; try { Bitmap loBMP = new Bitmap(lcFilename); ImageFormat loFormat = loBMP.RawFormat; decimal lnRatio; int lnNewWidth = 0; int lnNewHeight = 0; //*** If the image is smaller than a thumbnail just return it if (loBMP.Width < lnWidth && loBMP.Height < lnHeight) return loBMP; if (loBMP.Width > loBMP.Height) { lnRatio = (decimal)lnWidth / loBMP.Width; lnNewWidth = lnWidth; decimal lnTemp = loBMP.Height * lnRatio; lnNewHeight = (int)lnTemp; } else { lnRatio = (decimal)lnHeight / loBMP.Height; lnNewHeight = lnHeight; decimal lnTemp = loBMP.Width * lnRatio; lnNewWidth = (int)lnTemp; } // System.Drawing.Image imgOut = // loBMP.GetThumbnailImage(lnNewWidth,lnNewHeight, // null,IntPtr.Zero); // *** This code creates cleaner (though bigger) thumbnails and properly // *** and handles GIF files better by generating a white background for // *** transparent images (as opposed to black) bmpOut = new Bitmap(lnNewWidth, lnNewHeight); Graphics g = Graphics.FromImage(bmpOut); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight); g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight); loBMP.Dispose(); } catch { return null; } return bmpOut; } } |
Kullanımı ise aşağıdaki gibidir http://www.domain.com/thumbnail.aspx?image=resim_yolu.jpg&size=resim_boyut Herkese bol debuglu bol queryli […]
Merhaba arkadaşlar .net ortamında kod yazarken ” Fatal error encountered during command execution. ” şeklinde uyuz bir hata ile karşılaşmanızın pek çok sebebi olmakla beraber en çok nedeni sql sorgularınızda kullanmış olduğunuz parametrelerin karşılığının olmamasından dolayı bu hata fırlatabiliyor. Çözümü ; Sorgu içersinde karşılık gelen tüm parametreleri teker teker kontrol edin.
Merhaba arkadaşlar web tarafında kod yazarken excel’den import vsss işlemler yapmanız için aşağıdaki kodlar işinizi görücektir. Form tarafından 1 adet fileupload component ile upload işlemini yaptığınız varsayıyorum.Eğer excelden gelen verileri direk repeater bind edicekseniz aşağıdaki kodu kullanıcaksınız.
1 2 3 4 5 6 7 8 9 10 |
System.Data.OleDb.OleDbConnection MyConnection; System.Data.DataSet DtSet; System.Data.OleDb.OleDbDataAdapter MyCommand; MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/teknoloji/temp/") + rast + fonk.seo(excel_file.FileName) + ";Extended Properties='Excel 8.0;HDR=Yes'"); MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sayfa1$] where Urun_Kodu<>''", MyConnection); DtSet = new System.Data.DataSet(); MyCommand.Fill(DtSet); excel_iceri_aktarim.DataSource = DtSet; excel_iceri_aktarim.DataBind(); excel_iceri_aktarim.Dispose(); |
Form tarafından Eval kısmında ise <%#Eval(“Excel’deki sütun adı”) %> şeklinde kullanıcaksınız.Yok ben satır satır alıcam diyorsanız aşağıdaki kodu […]
Merhaba arkadaşlar, üyelik formlarında veya önemli bilgilerin bulunduğu alanlarda md5 şifreleme kullanarak verilerinizi güvenli hale getirebilirsiniz.Öncelikle aşağıdaki kütüphaneleri yüklüyoruz.
1 2 |
using System.Text; using System.Security.Cryptography; |
Daha sonra aşağıdaki fonksiyonumuzu kullanarak istediğimiz yerde md5 şifrelemesi yapabiliriz.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public string md5(string deger) { byte[] ByteData = Encoding.ASCII.GetBytes(deger); MD5 oMd5 = MD5.Create(); byte[] HashData = oMd5.ComputeHash(ByteData); StringBuilder oSb = new StringBuilder(); for (int x = 0; x < HashData.Length; x++) { oSb.Append(HashData[x].ToString("x2")); } return oSb.ToString(); } |
Merhaba arkadaşlar; Asp.net rewrite url ile postback işlemi yapmak istediğinizde eğer form action değerini belirtiğinizde normalde http://ww.domain.com/url/ikinci_adres gibi olması lazımken postback olduğunda http://ww.domain.com/url/ikinci_adres?default.asp?kid=2 şeklinde dönüşmektedir.Bunun çözümü çok basit olmasına ragmen insanı uyuz edebilmektedir.Çözümü işe page_load a aşağıdaki kod eklemektedir. Form.Action = Request.RawUrl;