Ürfet Demirtaş
Bozkırın yağız programcısı...

ANASAYFA | HAKKIMDA | ASP.NET WEB FORM | C# | BİLGİ GÜVENLİĞİ | LINQ | T-SQL | ASP.NET MVC | GENEL | İLETİŞİM
 
 
MAKALE ARA

Asp.net resim küçültme Class'ı

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

public class ResimBicim
{

    public static void yukle(FileUpload fu)
    {

        System.Drawing.Image orjinalFoto = null;

        HttpPostedFile jpeg_image_upload = fu.PostedFile;

        orjinalFoto = System.Drawing.Image.FromStream(jpeg_image_upload.InputStream);

        boyutlandir(orjinalFoto, 500, fu.FileName);

    }

    protected static void boyutlandir(System.Drawing.Image orjinalFoto, int boyut, string dosyaAdi)
    {

        System.Drawing.Bitmap islenmisFotograf = null;

        System.Drawing.Graphics grafik = null;

        int hedefGenislik = boyut;

        int hedefYukseklik = boyut;

        int new_width, new_height;

        new_height = (int)Math.Round(((float)orjinalFoto.Height * (float)boyut) / (float)orjinalFoto.Width);

        new_width = hedefGenislik;

        hedefYukseklik = new_height;

        new_width = new_width > hedefGenislik ? hedefGenislik : new_width;

        new_height = new_height > hedefYukseklik ? hedefYukseklik : new_height;

        islenmisFotograf = new System.Drawing.Bitmap(hedefGenislik, hedefYukseklik);

        grafik = System.Drawing.Graphics.FromImage(islenmisFotograf);

        grafik.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.White), new System.Drawing.Rectangle(0, 0, hedefGenislik, hedefYukseklik));

        int paste_x = (hedefGenislik - new_width) / 2;

        int paste_y = (hedefYukseklik - new_height) / 2;

        grafik.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

        grafik.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

        grafik.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

        System.Drawing.Imaging.ImageCodecInfo codec = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1];

        System.Drawing.Imaging.EncoderParameters eParams = new System.Drawing.Imaging.EncoderParameters(1);

        eParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 95L);

        grafik.DrawImage(orjinalFoto, paste_x, paste_y, new_width, new_height);

        islenmisFotograf.Save(HttpContext.Current.Server.MapPath("~/" + dosyaAdi), codec, eParams);

    }
}


Kullanımı;

    protected void Button1_Click(object sender, EventArgs e)
    {
        ResimBicim.yukle(FileUpload1);
    }

Detay [..]

Asp.Net Kontrolleri - Attributes

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        Button1.Attributes.Add("onmouseover", "alert('Buton 1 in üzerine gelindi')");
    }
    else
    {
        Button1.Attributes.Remove("onmouseover");
    }
}
Detay [..]

MasterPage kullanımda kontrollerin ID mevzusu

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DefaultMaster.aspx.cs" Inherits="DefaultMaster" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script><script src="jquery.maskedinput-1.2.2.min.js" type="text/javascript"></script>
 <script type="text/javascript">

        jQuery(function($) {

            $("#<%=date.ClientID %>").mask("99/99/9999");

            $("#<%=phone.ClientID %>").mask("(999) 999-9999");

            $("#ctl00_ContentPlaceHolder1_tin").mask("99-9999999");

            $("#ctl00_ContentPlaceHolder1_ssn").mask("999-99-9999");

        });   

    </script>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table border="0">
        <tbody>

            <tr><td>Date</td><td><asp:TextBox runat="server" ID="date" /></td><td>99/99/9999</td></tr>

            <tr><td>Phone</td><td><asp:TextBox runat="server" ID="phone" /></td><td>(999) 999-9999</td></tr>

            <tr><td>Tax ID</td><td><asp:TextBox runat="server" ID="tin" /></td><td>99-9999999</td></tr>

            <tr><td>SSN</td><td><asp:TextBox runat="server" ID="ssn" /></td><td>999-99-9999</td></tr>

        </tbody>
    </table>
</asp:Content>

 

Detay [..]

asp.net ie deki gibi geri butonu

1- Buton

<form>
<input type="button" value="Back to Previous Page"
onClick="javascript: history.go(-1)">
</form>

 

2- Link

<a href="javascript: history.go(-1)">Back</a>

3- Link

<a href="#" onclick="history.go(-1);return false;">BACK</a>


Detay [..]

xml den veri okuma

    protected void btnXmlOku_Click(object sender, EventArgs e)
    {
        DataSet verioku = new DataSet();
        verioku.ReadXml(@"c:\XmlDosya.xml");
        this.GridView1.DataSource = verioku.Tables[0];
        this.GridView1.DataBind();
    }

Detay [..]

DataSet'deki tabloyu xml'e yazdırma

   protected void btnXmlYaz_Click(object sender, EventArgs e)
    {
        string baglan = "Data Source=.\\sqlexpress;" + "initial Catalog=...;integrated security=sspi";
 
        SqlConnection conn = new SqlConnection(baglan);
        string sorgu = "select  *  from tblBilgiler";
        SqlDataAdapter sadp = new SqlDataAdapter(sorgu,conn);
        DataSet ds = new DataSet();
        sadp.Fill(ds);
        
       // XML DOSYA OLUSTUR
        ds.WriteXml(@"c:\XmlDosya.xml");
        Response.Write("Dosya Oluşturuldu");
    }

Detay [..]

Veritabanından Çekilen Sıraya Göre User Control

protected void Page_Load(object sender, EventArgs e)
{

    DataTable insDataTable = new DataTable();

    insDataTable.Columns.Add("UserControl", typeof(string));

    insDataTable.Columns.Add("SiraNo", typeof(int));

    insDataTable.Rows.Add("~/UserControls/WebUserControl1.ascx", 1);

    insDataTable.Rows.Add("~/UserControls/WebUserControl3.ascx", 2);

    insDataTable.Rows.Add("~/UserControls/WebUserControl2.ascx", 3);

 

    //bu verinin veri tabanindan sirali geldigini dusunun.

    //sayfa uzerinde bir tane panel oldugunu ve adinin da pnlMenu oldugunu dusunun

 

    foreach (DataRow dr in insDataTable.Rows)
    {

        Control u = this.LoadControl(dr["UserControl"].ToString());

        pnlMenu.Controls.Add(u);

    }
}

Detay [..]

asp.net bir sitenin html bilgilerini çekmek

using System.Net;
using System.IO;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        WebRequest request = WebRequest.Create("http://www.urfetdemirtas.com/");

        request.Method = "POST";

        string postData = "http://www.urfetdemirtas.com/";

        byte[] byteArray = Encoding.UTF8.GetBytes(postData);

        request.ContentType = "application/x-www-form-urlencoded";

        request.ContentLength = byteArray.Length;

        Stream dataStream = request.GetRequestStream();

        dataStream.Write(byteArray, 0, byteArray.Length);

        dataStream.Close();

        WebResponse response = request.GetResponse();

        Console.WriteLine(((HttpWebResponse)response).StatusDescription);

        dataStream = response.GetResponseStream();

        StreamReader reader = new StreamReader(dataStream);

        string responseFromServer = reader.ReadToEnd();

        TextBox1.Text = responseFromServer.ToString();
    }
}

Detay [..]

asp.net session ile yetki kontrolü

if((Session[kullanici_id].tostring() !="1") && (Session["yetki_id].tostring() !="1"))
{
}
else
{
}

Detay [..]

Url Gizleme Server.Transfer("Url.aspx");

protected void LinkButton1_Click(object sender, EventArgs e)
{
   Server.Transfer("2.aspx");
}

Detay [..]
 
Görüntülenen Sonuçlar 31 ile 40 arası ( Toplam Kayıt 74)
Sayfa: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8  « Geri · İleri »
 


Şairin de dediği gibi; 'programcı' adama hazır blog yakışmazdı.

Ürfet Demirtaş (2010) C#.Net