Friday, November 28, 2008

Internet Traffic 2007

last semester I had a lecture called Peer to Peer network
if you dont know whats Peer to Peer network read Wikipedia

Global internet traffic
HTTP 46%
P2P 37%


P2P Share Germany
HTTP 10%
P2P 73%



P2P systems Germany 2007 by volume
Bittorent 66%
eDonkey 28%
Gnutella 3%



What Germans Download by 2007
Movie 37 %
TV 21%
Por.n 13 %
Animation 7%
Music 7%
Game 5%
..

Wednesday, November 26, 2008

Thursday, November 13, 2008

Remove windows low disk alert in registary

in notepad save this text as lowdisk.reg and then run it

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000091
"NoLowDiskSpacechecks"=dword:00000001

Add faviorate icon to your website

Add this tag inside

<head>

<link href="'http://website.com/favicon.ico'" rel="'shortcut" type="'image/ico'/">

head>



HyperColumn in ASP.NET

<asp:TemplateColumn HeaderText="Link">

<ItemTemplate>Link

<asp:HyperLink runat="server" Text="<%# DataBinder.Eval(Container.DataItem, FLD)%>" NavigateUrl="http://localhost" title="<%#DataBinder.Eval(Container.DataItem, FLD)%>" >

asp:HyperLink>

ItemTemplate>

asp:TemplateColumn>



<asp:HyperLinkColumn Text="Link" DataNavigateUrlField="Code" DataNavigateUrlFormatString="/web/frmrpr.aspx?codeId={0}"

HeaderText="Link">

asp:HyperLinkColumn>



Dynamic Text in ASP.NET

div title="<%# DataBinder.Eval(Container.DataItem,"ColName") %> - <%# DataBinder.Eval(Container.DataItem,"note") %>"><asp:Label runat="server" ID="LblName" ToolTip='' Text='<%# Bind("ColName") %>' />div>

Multi File Upload ASP.NET

<%@ Page Language="C#" Debug="true"%>

<script runat="server">

void Button1_Click(object Source, EventArgs e)

{

txtMsg.InnerHtml = saveFiles();

}


string saveFiles() {

string strMessage = "";

string strFileName;

HttpPostedFile objFile;

for (int i=0; i

objFile = Request.Files[i];

if (objFile.FileName != "") {

strFileName = objFile.FileName;

strFileName = strFileName.Substring(strFileName.LastIndexOf("\\")+1);

try {

objFile.SaveAs("c:\\upload\\"+strFileName);

strMessage+= "Uploaded: c:\\upload\\"+strFileName+"
"
;

}

catch (Exception err) {

strMessage+= "Failed uploading "+strFileName+": "+err.ToString()+"
"
;

}

}

}

return strMessage;

}

script>



<html>

<head>

<title>Multiple File Upload with ASP.NETtitle>

head>

<body>

<b>Multiple File Upload Sampleb>

<form id="frmUp" enctype="multipart/form-data" runat="server">

Select file for upload:

<input id="txtFile" type="file" runat="server">

<br>

Select file for upload:

<input id="txtFile2" type="file" runat="server">

<br>

Select file for upload:

<input id="txtFile3" type="file" runat="server">

<br>

<span id=txtMsg runat="server" />

<br>

<input type=button id="Button1" value="Upload" OnServerClick="Button1_Click" runat="server">

form>

</body>

html>

Crystal Report in Visual studio 2003

ReportDocument CrReport = new ReportDocument();

CrReport.Load("report\\report.rpt");

ParameterFields ParamFields=new ParameterFields();


ParamField=new ParameterField();

ParameterDiscreteValue spValue1=new ParameterDiscreteValue();

ParamField.ParameterFieldName ="@field";

ParamField.ParameterType = CrystalDecisions.Shared.ParameterType.StoreProcedureParameter;

spValue1.Value = value;

ParamField.CurrentValues.Add(spValue1);

ParamFields.Add(ParamField);


TableLogOnInfo myTableLogonInfo = new

CrystalDecisions.Shared.TableLogOnInfo();


myTableLogonInfo = CrReport.Database.Tables[0].LogOnInfo;

myTableLogonInfo.ConnectionInfo.ServerName = "Servername";

myTableLogonInfo.ConnectionInfo.DatabaseName = "DB";

myTableLogonInfo.ConnectionInfo.UserID = "sa";

myTableLogonInfo.ConnectionInfo.Password="pass";


CrReport.Database.Tables[0].ApplyLogOnInfo( myTableLogonInfo);

CrystalReportViewer1.ParameterFieldInfo = ParamFields;

CrystalReportViewer1.ReportSource = CrReport ;

How to fix boot windows vista in Windows XP

the setup file of windows xp is in boot.ini c:\ as below
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows Vista Professional" /noexecute=optin /fastdetect


if you add the blue line manually to boot.ini , windows xp will not boot because windows vista is not booting from boot.ini

vista will use BCD which is in drive C:\ and if you recover your C drive.
you can fix your BCD by using EasyBCD software.

after installing EasyBCD you need to run it, then it will ask you to add BCD automatically to you boot.
its better to do it manually and give your drive as vista drive and it will add in this address c:\boot new boot.


if you restart now your windows vista will just boot.
then you need to add windows xp to boot.

go to Add/Remove entries from Add an Entry choose Windows NT/2k/xp/2k3 and give your windows XP drive as following picture...



if you want to be sure just go to view setting

There are a total of 2 entries listed in the Vista Bootloader.
Bootloader Timeout: 5 seconds.
Default OS: Windows Vista

Entry #1

Name: Windows Vista
BCD ID: {default}
Drive: D:\
Bootloader Path: \Windows\system32\winload.exe
Windows Directory: \Windows

Entry #2

Name: Microsoft Windows Xp
BCD ID: {d4310162-08ee-11dd-a7c7-00059a3c7800}
Drive: C:\
Bootloader Path: \NTLDR

Download EasyBCD

you can do the same process with VistaBootPro but it needs Microsoft .NET framework 2 as prerequsit to run.

How to automatically refresh a ASP.NET page

Add this to header in ASP.NET
Response.AppendHeader("Refresh", "10; URL=http://www.softminer.net");

How to run windows API in C#

#region "API"
[DllImport("shell32.dll")]

public static extern int ShellExecute(int hwnd,string lpOperation,string lpFile,string lpParameters,string lpDirectory,int nShowCmd);
public const int SW_MAXIMIZE = 3;
public const int SW_NORMAL = 1;
#endregion "API"

Run query from another computer in SQL Server

DeviceName is the name of another sqlinstance

EXEC sp_addlinkedserver @server='sqlinstance', @srvproduct='',@provider='SQLOLEDB',@datasrc='sqlinstance\instance1'


EXEC sp_addlinkedsrvlogin 'sqlinstance', 'false', NULL, 'sa', ''

select * from sqlinstance.Table.dbo.linklist

Tuesday, November 11, 2008

How to add session timeout in ASP.NET

Add this into web.config inside


<sessionState mode="InProc" cookieless="false" timeout="60"/>

Disable HTML validation on ASP.NET

bz default it is not possible to write HTML tag in Textbox in ASP.NET, if you want to disable it, just add this tag to the page header ValidateRequest="false"

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmLogin.aspx.cs" Inherits="frmLogin" ValidateRequest="false" %>

Decimal division problem in C#

if you divide two int then the result is always integer even if you save it in Decimal.

int A = 32;
int B = 36;
decimal result = A / B;

then the result = 0

but if you use
decimal A = 32;
decimal B = 36;
decimal result = A / B;

then the result = 0.8888888888

Free TextEditor

Hier you can find free TextEditor for ASP.NET : http://freetextbox.com/

this is the Demo

Screenshot