Pages

Graduated

        I have graduated  from Mathematical engineering at Yıldız technical university. It was good to be a student after 4.5  years. I established good friendships from here and I cant estimate the price for this. I would like to say thanks very much to all my teachers and supervisors and friends.

diploma

hehe  congratulations to me Smile

Setting culture at page and codebehind

 

Setting culture with C#
protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
// Define the language
UICulture = Request.Form["DropDownList1"];
// Define the formatting (requires a specific culture)
Culture = Request.Form("DropDownList1");
}
base.InitializeCulture();
}

Also if you want to do this setting from page without dont write anything in c# code you can just write this top of the page
<%@ Page UICulture="es" Culture="es-MX" %>

Create Dynamic Master Page


if you want create your dynamic masterpage in your website you can just use this kind of codepart at your code.

Session["masterpage"] = "Master2.master";
Response.Redirect(Request.Url.ToString());

void Page_PreInit(Object sender, EventArgs e)
{
if (Session["masterpage"] != null)
MasterPageFile = (String)Session["masterpage"];
}

Using the XPathNavigator to Search XPathDocuments

protected void Button8_Click(object sender, EventArgs e)
{
lbl = GetLabel(275, 20);
string s;
XPathDocument xmlDoc = new XPathDocument(MapPath("iboxml.xml"));
XPathNavigator nav = xmlDoc.CreateNavigator();
string expr = "//myChild[@ChildID='ref-3']";
//Display the selection
XPathNodeIterator iterator = nav.Select(expr);
XPathNavigator navResult = iterator.Current;
while (iterator.MoveNext())
{
s = String.Format("<b>Type:</b>{0} <b>Name:</b>{1} ",navResult.NodeType, navResult.Name);
if (navResult.HasAttributes)
{
navResult.MoveToFirstAttribute();
s += "<b>Attr:</b> ";
do
{
s += String.Format("{0}={1} ",navResult.Name, navResult.Value);
}
while (navResult.MoveToNextAttribute());
}
lbl.Text += s + "<br>";
}
}

Solving "The project file ' ' has been renamed or is no longer in the solution"

We were recently faced with the error message The project file ' ' has been renamed or is no longer in the solution in Visual Studio 2008. The problem is that from this message you have no idea what is actually the matter. We finally figured out that this happens when a Web Project contains references to assemblies or projects it can't find. Here's how you solve this:

    Right click the Web project and select Property Pages.
    A window will open which lists all the references, either to the bin-folder, GAC or other projects in the solution.
    Remove those that show (unavailable) behind it.
    Chances are that now you can't build because the reference is not there. Simply add the reference again and you should be OK

Windows Identy / Windows Principal

identity3 MPj03415220000[1]

User identity is a common means of controlling access to a business application or limiting the options available within that application. The .NET Framework classes under the namespace System.Security.Principal are provided to assist in making such role-based security determinations.

*firstly you must add this dll :
System.Security.Principal;   System.Security.Policy;
then:
The Framework provides a WindowsIdentity class that represents an authenticated Windows user and a WindowsPrincipal class that encapsulates the WindowsIdentity and information about the user's role memberships. These objects representing the current user are accessible in one of two ways: using a static property on the Thread object or a static method on the WindowsIdentity object.
you can see example of windows identity and windows principal ;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        { 
            WindowsIdentity kimlik = WindowsIdentity.GetCurrent();
            Console.WriteLine(kimlik.Name.ToString());
            Console.WriteLine(kimlik.Token.ToString());
            Console.WriteLine(kimlik.AuthenticationType.ToString());

            if (kimlik.IsAnonymous)
                Console.WriteLine("Genel kullanıcı");
            if (kimlik.IsGuest)
                Console.WriteLine("Misafir kullancı");

            kimlik = WindowsIdentity.GetCurrent();
            WindowsPrincipal kimlik2 = new WindowsPrincipal(kimlik);
            Console.WriteLine(WindowsBuiltInRole.Administrator);
            kimlik2.IsInRole(WindowsBuiltInRole.Administrator);
            Console.ReadLine();

        }
    }
}

you will see like this when you run your code ….image

Make your own Tcp Server/ Client

tcp-ip




    In this tutorial I’m going to show you how to make a tcp server with C#. If you ever work with windows’ sockets , you already know how difficult this can sometimes be. However you can see how it can be easy in .net platform.

* firstly you must add which name space you need for network programming.
using System.Net;
using System.Net.Sockets;
And then you can write this code ;

image  
Now Just start to explain our code.In main function you just define your class instance which name is Initialize and use it’s method which is called StartListen.And in this method we just  called the StartStream method firstly.
At the StartStream method our first work is defining  our variable.After this We must send parameter to TcpListener object what it needs.
*newsock = new TcpListener(IPAddress.Any, Convert.ToInt32(port));    => here we define ip adres and port for listener.
*newsock.Start();   =>
Just started our TcpListener.
*client = newsock.AcceptTcpClient();   =>  this code part is blocking until a client is connected to the  server and accepts a pending connection request.
*ns = client.GetStream();   => set our networkStream to send or receive data. 
* In the StartListen method, you define byte array and use networkstream write method.
byte[] dizi = Encoding.ASCII.GetBytes(LA);  
ns.Write(dizi, 0, dizi.Length);  

Attention ! please dont forget to close your stream after all works are  over.Like these =>   
newsock.Stop();  client.Close(); ns.close();


At client side, you can use this code block for read data from tcpserver. And you can find explanation about every statement why we use it.


byte [] data = new byte[1024];
//this line is about reading data from networkstream
// and just for learning to find how many byte we use in array which name is ‘data’
recv = ns.Read(data, 0, data.Length);
//at here, we convert our data type byte to string  
string ss = Encoding.ASCII.GetString(data, 0, recv);
// after this line you can do what you want …

Get data from xml file

 

images Today I decided to write my article about xml , firstly I want to say somethink about my grammar ,this is my first article that I use english so I m sory if I make mistake. :))

*Why we use xml file ?
*because in the real world, computer systems and databases contain data in incompatible formats.XML data is stored in plain text format. This provides a software- and hardware-independent way of storing data.This makes it much easier to create data that different applications can share.

XmlTextReader xmlDocument = new XmlTextReader("MyXmlFile.xml");

                while (xmlDocument.Read())
                {
                    if (xmlDocument.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlDocument.Name)
                        {
                            case "ip":
                                _IpAdres = Convert.ToString(xmlDocument.ReadString());
                                break;
                        }
                    }
                }
                xmlDocument.Close();

Console.WriteLine(IpAdres );

*XmlTextReader xmlDocument = new XmlTextReader("TcpServer.xml");
At this sentence you just defined your stream for reading  xml and set it’s parameter which is about file path .
*while (xmlDocument.Read())  after defined your stream, you can start reading the first line of your file
*xmlDocument.NodeType == XmlNodeType.Element  At this part of code you just verify your node type for sure it not root node. And then you can use switch  to take your node name  .
* when you found  which name you search you could read that line and convert which type you want  same this =>   _IpAdres = Convert.ToString(xmlDocument.ReadString());

C# ile Tek Kullanımlık Şifre Üretmek

B-3280~1

public string Sifre ()
{
Byte[] bit = new Byte[10];
new Random().NextBytes(bit);

//Console.WriteLine(BitConverter.ToString(bit));
String sifre = Convert.ToBase64String(bit);

return sifre ;

}  

JavaScript kodundan server taraflı fonksiyon çağırmak

sayfanızın .cs tarafında hazırladığınız bir fonksiyonu javascript kodu içinden çağırmak istiyorsanız şu adımları izleyebilirsiniz

//.cs sayfasında

public string Fonksiyonum()

{

//işlemler

return “islemler yapildi”

}

//script tagları arasında

function fonksiyonCagir()

{

var gelen = ‘<% = Fonksiyonum() %>’

window.alert(gelen);

}

Visual C# Kısa yolları

Posterinizi aşağıdaki linkten indirebilirsiniz..

http://www.microsoft.com/downloads/details.aspx?FamilyID=e5f902a8-5bb5-4cc6-907e-472809749973&displaylang=en

sizdemi teknolojiyi seviyorsunuz?

image

Windows 7'nin kesin çıkış tarihi açıklandı

Şirketten yapılan açıklamaya göre yeni işletim sisteminin kullanıcılarıyla buluşacağı tarih 22 Ekim 2009 olarak açıklandı. Mevcut lisanslı Windows kullanıcılarına terfi programı da aynı tarihte sunulacak. Açıklama Taipei'de düzenlenen Computex fuarında Microsoft'un başkan yardmcılarından Steve Guggenheimer tarafından yapıldı. Microsoft'tan daha önce yapılan açıklamalarda "yıl sonuna doğru" ifadesi kullanılıyor, kesin bir tarih verilmiyordu. Halen beta sürümü kullanımda olan Windows 7 ile ilgili kullanıcıların ilk izlenimleri ise genelde olumlu. Microsft'tan yapılan açıklamaya göre Windows 7'nin netbook'lar dahil tüm PC'lerde çalışacağı belirtilmişti.

AJAX Control Toolkit Release Notes - May 2009 Release Version 3.0.30512

New controls

This release includes three important new controls:

    HTMLEditor

    The HTMLEditor control allows you to easily create and edit HTML content. You can edit in design mode, as a rich text editor, or in source view to edit the HTML markup directly.

    ComboBox

    The ComboBox control provides a DropDownList of items, combined with TextBox. Different modes determine the interplay between the text entry and the list of items.

    ColorPicker

    The ColorPicker Control Extender can be attached to any ASP.NET TextBox control. It provides client-side color-picking functionality with UI in a popup control.any thanks to Alexander Turlov for building this.