İbrahİm Özbey
just for software development
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.
hehe congratulations to me
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
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 if (kimlik.IsAnonymous) kimlik = WindowsIdentity.GetCurrent(); } |
Make your own Tcp Server/ Client
* 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 ;
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.
|
Get data from xml file
XmlTextReader xmlDocument = new XmlTextReader("MyXmlFile.xml"); while (xmlDocument.Read()) 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
public string Sifre () //Console.WriteLine(BitConverter.ToString(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..
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.
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.
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.