Monday, December 24, 2012

What is Inheritance?


What is Inheritance?

Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (concept) of object-oriented programming Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes The Class whose methods and variables are defined is called super class or base class The Class that inherits methods and variables are defined is called sub class or derived class Sometimes base class known as generalized class and derived class known as specialized class Keyword to declare inheritance is ":" (colon) in visual C#.

Benefits of using Inheritance

Once a behavior (method) or property is defined in a super class(base class),that behavior or property is automatically inherited by all subclasses (derived class). Code reusability increased through inheritance Inheritance provide a clear model structure which is easy to understand without much complexity Using inheritance, classes become grouped together in a hierarchical tree structure Code are easy to manage and divided into parent and child classes

Example of Inheritance

Types of Inheritance in C#: -

  • Implementation Inheritance
  • Multiple Inheritances (Interface Inheritance)

Implementation Inheritance

One base class (super class) and one derived class (sub class).

Example:

 


Interface Inheritance

An interface looks like a class, but has no implementation. It contains definitions of events, indexers, methods and properties. An interface inherited by classes An interface inheritance defined with keyword "interface". In C# Interface Inheritance also known as multiple inheritances.

Inheritance Tree Structure:

 

Sunday, December 23, 2012

Difference between Abstract Class and Interface


  • An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.

An example of interface:

interface iSampleInterface
{
  //All methods are automaticall abstract
  int AddNumbers(int Num1, int Num2);
  int MultiplyNumbers(int Num1, int Num2);
}



  • Defining an abstract class with abstract members has the same effect to defining an interface.
  • The members of the interface are public with no implementation. Abstract classes can have protected parts, static methods, etc.
  • A class can inherit one or more interfaces, but only one abstract class.
  • Abstract classes can add more functionality without destroying the child classes that were using the old version. In an interface, creation of additional functions will have an effect on its child classes, due to the necessary implementation of interface methods to classes.
  • The selection of interface or abstract class depends on the need and design of your project. You can make an abstract class, interface or combination of both depending on your needs.

What is delegate? how to use Delegates ?


What is delegate?
Delegates are objects you can use to call the methods of other objects.
A delegate is a type that safely encapsulates a method, similar to a function pointer in C and C++. Unlike C function pointers, delegates are object-oriented, type safe, and secure. The type of a delegate is defined by the name of the delegate.
Once a delegate is assigned a method, it behaves exactly like that method.
The delegate method can be invoked like any other method, with parameters and a return value.
Any method from any accessible class or struct that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate.
The method can be either static or an instance method. This makes it possible to programmatically change method calls, and also plug new code into existing classes. As long as you know the signature of the delegate, you can assign your own delegated method.
Delegates have the following properties:
Delegates are like C++ function pointers but are type safe.
Delegates allow methods to be passed as parameters.
Delegates can be used to define callback methods.
Delegates can be chained together; for example, multiple methods can be called on a single event.
Methods do not have to match the delegate signature exactly.

how to use Delegates ?


or



1. Defining the delegate
 
public delegate int Calculate (int value1, int value2);
 2. Creating methods which will be assigned to delegate object
 
//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int add(int value1, int value2)
{
    return value1 + value2;            
}//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int sub( int value1, int value2)
{
    return value1 - value2;            
}
 3. Creating the delegate object and assigning methods to those delegate objects
 
//creating the class which contains the methods 
//that will be assigned to delegate objectsMyClass mc = new MyClass();
//creating delegate objects and assigning appropriate methods
//having the EXACT signature of the delegateCalculate add = new Calculate(mc.add);
Calculate sub = new Calculate(mc.sub);
 4. Calling the methods via delegate objects
 
//using the delegate objects to call the assigned methods Console.WriteLine("Adding two values: " + add(10, 6));
Console.WriteLine("Subtracting two values: " + sub(10,4));

Monday, November 19, 2012

3 tier architecture


using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Data;
using System.Collections;
DAL:

namespace DAL
{
   public class DbConnection
    {
        SqlConnection con;
        SqlCommand cmd;
        SqlDataAdapter adp;
        StringBuilder sb;
        SqlDataReader _rdr;

        public DbConnection()
        {
            con = new SqlConnection(ConfigurationSettings.AppSettings["conn"].ToString());
            sb = new StringBuilder("");
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        public void OpenDbConnection()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
        }
        public void CloseDbConnection()
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
        public SqlCommand GetDbCommand()
        {
            if (cmd != null)
            {
                return cmd;
            }
            else
            {
                cmd = new SqlCommand();
                cmd.Connection = con;
                return cmd;
            }
        }
        public int ExecuteNonQuery(string _spname, SqlParameter[] sp_param)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = _spname;
            foreach (SqlParameter _parm in sp_param)
            {
                cmd.Parameters.Add(_parm);
            }
            int i = cmd.ExecuteNonQuery();
            return i;
        }
        public ArrayList GetAdminLogininfo(string username, string password)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Pipe_SP_AdminLogin";
            cmd.Parameters.AddWithValue("@username", username);
            cmd.Parameters.AddWithValue("@password", password);
            cmd.Parameters.Add("@returnVar", SqlDbType.Bit);
            cmd.Parameters["@returnVar"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@ID", SqlDbType.Int);
            cmd.Parameters["@ID"].Direction = ParameterDirection.Output;
                 
            cmd.ExecuteNonQuery();
            ArrayList result = new ArrayList();
            result.Add(cmd.Parameters["@returnVar"].Value);
         
            result.Add(cmd.Parameters["@ID"].Value);
     

            return result;
       
                }
        public ArrayList GetRepLogininfo(string username, string password)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Pipe_SP_RepLogin";
            cmd.Parameters.AddWithValue("@username", username);
            cmd.Parameters.AddWithValue("@password", password);
            cmd.Parameters.Add("@returnVar", SqlDbType.Bit);
            cmd.Parameters["@returnVar"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@ID", SqlDbType.Int);
            cmd.Parameters["@ID"].Direction = ParameterDirection.Output;

            cmd.ExecuteNonQuery();
            ArrayList result = new ArrayList();
            result.Add(cmd.Parameters["@returnVar"].Value);

            result.Add(cmd.Parameters["@ID"].Value);


            return result;

        }
        public ArrayList GetClientLogininfo(string Email, string password)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "SUB_SP_GetClientLoginInfo";
            cmd.Parameters.AddWithValue("@Email", Email);
            cmd.Parameters.AddWithValue("@password", password);
            cmd.Parameters.Add("@returnVar", SqlDbType.Bit);
            cmd.Parameters["@returnVar"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@ClientID", SqlDbType.Int);
            cmd.Parameters["@ClientID"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@OrgId", SqlDbType.VarChar, 50);
            cmd.Parameters["@OrgId"].Direction = ParameterDirection.Output;
            cmd.ExecuteNonQuery();
            ArrayList result = new ArrayList();
            result.Add(cmd.Parameters["@returnVar"].Value);
            result.Add(cmd.Parameters["@ClientID"].Value);
            result.Add(cmd.Parameters["@OrgID"].Value);

            return result;
        }



        public DataTable ExecuteDataTable(string _spname, SqlParameter[] sp_param)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = _spname;
            if (sp_param != null)
            {
                foreach (SqlParameter _parm in sp_param)
                {
                    cmd.Parameters.Add(_parm);
                }
            }
            DataSet dt = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(dt);
            adp.Dispose();
            cmd.Dispose();
            CloseDbConnection();
            return dt.Tables[0];
        }
        public int ExecuteScalar(string _sql)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = _sql;
            int count = int.Parse(cmd.ExecuteScalar().ToString());
            cmd.Dispose();
            CloseDbConnection();
            return count;
        }
        public SqlDataReader ExecuteReader(string _sql)
        {
            OpenDbConnection();
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = _sql;
            _rdr = cmd.ExecuteReader();
            return _rdr;
        }
        public DataTable ExecuteDT(string _Sql)
        {
            cmd = GetDbCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = _Sql;
            DataSet dt = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(dt);
            adp.Dispose();
            cmd.Dispose();
            return dt.Tables[0];
        }
        //public SqlDataAdapter GetDataAdaptor()
        //{
        //    if (adp != null)
        //    {
        //        return adp;
        //    }
        //    else
        //    {
        //        adp = new SqlDataAdapter(;

        //    }
        //}
    }


}


BAL :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DAL;

namespace BAL
{
   public class ClsAddLeads
    {

        #region "Properties"

        public int ID { get; set; }
        public int RepsID { get; set; }
        public int LeadsID { get; set; }
        public DateTime DateAdded { get; set; }
        public string Fname { get; set; }
        public string Contact { get; set; }
        public string Position { get; set; }
        public DateTime LastContactDate { get; set; }
        public string Phone { get; set; }
        public string LegacyPartner { get; set; }
        public string Investment { get; set; }
        public string Notes { get; set; }  
        public string Mode { get; set; }

        #endregion

        #region "All Insert,Update,Delete operation are done"
        public int Leads()
        {
            DbConnection _clsdb = new DbConnection();
            SqlParameter[] _sp = new SqlParameter[11];
            _sp[0] = new SqlParameter("@ID", ID);
            _sp[1] = new SqlParameter("@RepsID", RepsID);
            _sp[2] = new SqlParameter("@Fname", Fname);
            _sp[3] = new SqlParameter("@Contact", Contact);
            _sp[4] = new SqlParameter("@Position", Position);
            _sp[5] = new SqlParameter("@LastContactDate",Convert.ToDateTime(LastContactDate));
            _sp[6] = new SqlParameter("@Phone", Phone);
            _sp[7] = new SqlParameter("@LegacyPartner", LegacyPartner);
            _sp[8] = new SqlParameter("@Investment", Investment);
            _sp[9] = new SqlParameter("@Notes", Notes);
            _sp[10] = new SqlParameter("@mode", Mode);
            
            int i = _clsdb.ExecuteNonQuery("Pipe_SP_Leads", _sp);
            return i;
        }

        public int AddRepsLeads()
        {
            DbConnection _clsdb = new DbConnection();
            SqlParameter[] _sp = new SqlParameter[5];
            _sp[0] = new SqlParameter("@ID", ID);
            _sp[1] = new SqlParameter("@RepsID", RepsID);
            _sp[2] = new SqlParameter("@LeadsID",LeadsID);
            _sp[3] = new SqlParameter("@DateAdded", DateAdded);
            _sp[4] = new SqlParameter("@mode", Mode);

            int i = _clsdb.ExecuteNonQuery("Pipe_SP_Leads", _sp);
            return i;
        }
        #endregion


        #region "LoadAll Leads Details"
        public DataTable GetLeads()
        {
            string sql = "select * from Pipe_TBL_AddLeads where Fname='" + Fname + "'";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);

            return dt;
        }

        public DataTable GetReps()
        {
            string sql = "select * from Pipe_TBL_RepsLeads where LeadsID='"+ LeadsID +"' order By ID ";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);

            return dt;
        }

        #endregion

        #region "All Insert,Update,Delete operation are done"
        public int DeleteLeads()
        {
            DbConnection _clsdb = new DbConnection();
            SqlParameter[] _sp = new SqlParameter[11];
            _sp[0] = new SqlParameter("@ID", ID);
            _sp[1] = new SqlParameter("@Fname", Fname);
            _sp[2] = new SqlParameter("@Contact", Contact);
            _sp[3] = new SqlParameter("@Position", Position);
            _sp[4] = new SqlParameter("@LastContactDate", null);
            _sp[5] = new SqlParameter("@Phone", Phone);
            _sp[6] = new SqlParameter("@LegacyPartner", LegacyPartner);
            _sp[7] = new SqlParameter("@Investment", Investment);
            _sp[8] = new SqlParameter("@Notes", Notes);
            _sp[9] = new SqlParameter("@mode", Mode);
            _sp[10] = new SqlParameter("@RepsID", RepsID);
            int i = _clsdb.ExecuteNonQuery("Pipe_SP_Leads", _sp);
            return i;
        }
        #endregion



        #region "LoadAll Leads Details"
        public DataTable LeadsDetails()
        {
            string sql = "select * from Pipe_TBL_AddLeads  order by ID";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);

            return dt;
        }

        #endregion

        #region "LoadAll Leads Details"
        public DataTable ShowLeads()
        {
            string sql = "select C.LeadsID,C.RepsID,A.ID,A.fname,A.Position,A.phone from Pipe_TBL_AddLeads as A , Pipe_TBL_RepsLeads as C where C.LeadsID=A.ID and  C.RepsID='" + RepsID + "' order by A.ID";
            //string sql = "select A.ID,A.RepsID,B.Fullname,A.fname,A.Position,A.phone from Pipe_TBL_AddLeads as A , Pipe_TBL_AddReps as B where A.RepsID=B.ID and A.RepsID='" + RepsID + "' order by A.ID";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);

            return dt;
        }

        #endregion

  

        #region "LoadAll Leads details by ID"
        public DataTable Leadsdata()
        {
            string sql = "select * from Pipe_TBL_AddLeads where ID='" + ID + "'";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);
            return dt;
        }

        #endregion


        #region "LoadAll Leads details by RepsID for Reports"
        public DataTable LeadsReport()
        {
           // string sql = "select ID,RepsID,fname,Position,CONVERT(VARCHAR(12),LastContactDate, 106) as LastContactDate,Phone ,Contact,LegacyPartner,Investment,Notes from Pipe_TBL_AddLeads where RepsID='" + RepsID + "'";

            string sql = "select C.LeadsID,C.RepsID,A.ID,A.fname,A.Position,A.phone,CONVERT(VARCHAR(12),A.LastContactDate, 106) as LastContactDate,Contact,LegacyPartner,Investment,Notes from Pipe_TBL_AddLeads as A , Pipe_TBL_RepsLeads as C where C.LeadsID=A.ID and  C.RepsID='" + RepsID + "' order by A.ID";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);
            return dt;
        }

        #endregion

        #region "LoadAll Leads details by RepsID"
        public DataTable LeadsdataByRepsID()
        {
            //string sql = "select A.ID,A.RepsID,B.Fullname,A.fname,A.Position,A.phone from Pipe_TBL_AddLeads as A , Pipe_TBL_AddReps as B where A.RepsID=B.ID and RepsID='" + RepsID + "' order by A.ID";
            string sql = "select C.LeadsID,C.RepsID,A.ID,A.fname,A.Position,A.phone from Pipe_TBL_AddLeads as A , Pipe_TBL_RepsLeads as C where C.LeadsID=A.ID and C.RepsID='" + RepsID + "' order by A.ID";

            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);
            return dt;
           
        }

        #endregion

        #region "Load Reps Name for reports"
        public DataTable RepsName()
        {
            string sql = "SELECT DISTINCT A.FullName as FullName FROM Pipe_TBL_AddReps as A,Pipe_TBL_AddLeads as B where B.RepsID=A.ID ORDER BY A.FullName";
            DbConnection _clsdb = new DbConnection();
            DataTable dt = _clsdb.ExecuteDT(sql);
            return dt;
        }

        #endregion

    }
}


PL:


   ClsAddLeads oRL = new ClsAddLeads();
                            oRL.RepsID = Convert.ToInt16(RepsselectedItem);
                            oRL.LeadsID =Convert.ToInt16(ViewState["ID"]);
                            oRL.DateAdded = DateTime.Now;
                            oRL.Mode = "RepsLeads";
                            int ok = oRL.AddRepsLeads();
                            if (ok == -1)
                            {

                                lblResult.Visible = true;
                                lblResult.ForeColor = Color.Green;
                                lblResult.Text = "Save successful ";
                            }





Friday, November 2, 2012

Remember me functionality in asp.net with VB.net using Cookies


 use the below code to save the userid and password deatils in cookies 

on login button:-

 If CheckBox1.Checked = True Then
                Response.Cookies("UName").Value = txtUserID.Text
                Response.Cookies("PWD").Value = txtPwd.Text
                Response.Cookies("UName").Expires = DateTime.Now.AddMonths(2)
                Response.Cookies("PWD").Expires = DateTime.Now.AddMonths(2)
End If


use the below code to Retrive the userid and password deatils From cookies 


on page load :-

  If Not IsPostBack Then
            If Request.Cookies("UName") IsNot Nothing Then
                txtUserID.Text = Request.Cookies("UName").Value
            End If
            If Request.Cookies("PWD") IsNot Nothing Then
                Dim pass As TextBox = DirectCast(Me.FindControl("txtPwd"), TextBox)
                pass.Attributes.Add("value", Request.Cookies("PWD").Value)
            
            End If
            If Request.Cookies("UName") IsNot Nothing AndAlso Request.Cookies("PWD") IsNot Nothing Then
                CheckBox1.Checked = True
            End If
        End If

Tuesday, May 8, 2012

How to clear a Multiple TextBox values in a single click in C# .NET


void ClearInputs(ControlCollection ctrls)
 {
        foreach (Control ctrl in ctrls)
        {
            if (ctrl is TextBox)
                ((TextBox)ctrl).Text = string.Empty;
            ClearInputs(ctrl.Controls);
        }
 }


protected void BtnSave_Click(object sender, EventArgs e)
{
           ClearInputs(Page.Controls);
}

Thursday, March 22, 2012

How to copy data from one table to another table in sql server

Syntax:- select * into NewTableName from ExistingTableName


Example:- select * into employee1 from employee


Note: where employee is the existing table. this query create a new table (employee1) and copy all the data of employee table in newly created table


        I hope this will help you!!

Friday, February 17, 2012

Introduction to PayPal


Introduction

PayPal is probably one of the first things that gets mentioned once you start discussion on online payments. It’s not so without reason – in 2008, PayPal moved over 60 billion dollars between accounts which is, you’ll agree, a respectable amount. And also, all trends show that this growth will continue – with huge number of new accounts (over 184 million accounts in 2008 compared to 96.2 million in 2005), with a new platform named PayPal X, and with more cool applications that involve paying (like Twitpay), you can bet that PayPal is here to stay. So, how can you join the whole PayPal Development movement?
Unfortunately, I would say – not so easily. When I first started with PayPal integration - it was hard, really hard. If you wish to see what I mean, just jump to the PayPal Developer Center. There is no way you’ll easily fish out what you need from that site if you are a PayPal newbie; simply - there are too many links, too many resources, and too many mixings of important and not-so-important information. So, how should you start?

Getting Started with PayPal

To those who really want to get into PayPal, and are willing to shell out some buck, I would recommend the Pro PayPal E-Commerce book - that’s how I eventually got into understanding the concepts behind PayPal integration. For those who are not so eager to pay – don’t worry, that’s why this article is here... I'll go over most of the stuff that book covers, but in a more brief and concise manner.
First and foremost - understanding what kinds of integration PayPal offers is, I would say, the most important thing in order to successfully start your development journey. A common mistake, that happened to me also, is to start at once with the PayPal API and Express Checkout. I mean it’s natural - we are developers, and when they tell us to integrate with something, the first thing we look for is the SDK & API… the PayPal API comes up as a result… we say “That’s it” to ourselves… and start working. The problem is – the majority of payment scenarios can be handled with a way simpler approach - HTML forms that are part of the Website Payments Standard.
So, without further ado, here is a classification of PayPal integrations:
  • Website Payments Standard (HTML)
  • Postpayment Processing
    • AutoReturn
    • Payment Data Transfer (PDT)
    • Instant Payment Notification (IPN)
  • PayPal API
    • Express Checkout
    • Direct Payment (Website Payments Pro)
  • Payflow Gateway
Items in classification are also ordered in a way I would suggest for everyone to follow. So, if you are new to PayPal – first learn all of the options that you have with the Website Payments Standard (HTML). Then, if you need to add some basic post-payment processing, see if Auto-Return or PDT will solve your problem… if not, IPN is a more robust option you have at your disposal.
The next level would involve the PayPal API and implementing the Express Checkout, which is the most flexible PayPal integration solution. And finally, if you long for the ability to directly process credit cards on your website, you’ll pay a monthly fee to PayPal and implement Direct Payment (effectively getting what is called Website Payments Pro).
The last item from our classification - the Payflow Gateway is, on the other hand, a different beast. It doesn’t “update the stack” in a way the previously mentioned technologies do. It is a solution aimed specifically at those businesses that have/want an Internet Merchant Account (IMA) and just need the payment gateway. In order to keep the article consistent, I’ll skip explaining the details of the Payflow Gateway. However, if you have any questions related to it, feel free to leave a message in the comments section and I’ll try to answer.
That said, let’s get to setting up a test PayPal account, and then we’ll delve deeper into describing the mentioned integrations.

Setting up a Test Account

Word of notice – you’ll want to follow this step even if you already have a live PayPal account. There are two reasons for using test accounts:
  • you don’t want to test and play with real money
  • you want to have access to different types of PayPal accounts
    • Personal account – most people have these; just an account that allows you to use PayPal when paying for stuff online. Theoretically, you can use a Personal account to accept money; just know that you’ll be severely constrained – there is a $500 receiving limit per month, and you are only able to accept one time payments using the Website Payments Standard (HTML). The big advantage of a Personal account is that you don’t need to pay any transaction fee when receiving money. Note, however, that if you receive more than $500 in one month, you’ll be prompted to either upgrade to a Premier/Business account or reject the payment.
    • Premier account – step up from a personal account; for anyone who wants to run a personal online business. This type of account has all of the integration options (accepting credit cards, recurring payments, PayPal API). However, most people skip directly from Personal to Business account as Premier account has the same transaction fees (in most cases, 2.9% + $0.30 per transaction) while lacking reporting, multi-user access, and other advanced merchant services of the Business account.
    • Business account – it has all of the features of the Premier account plus a few more (ability to operate under your business’s name is one of them). If you are developing a website that needs to accept payments in 99% of situations, you’ll go with this type of account.
To start, visit the PayPal Sandbox and sign-up for a new account. The process is straightforward, and most developers should have no trouble finishing it. However, here are the pictures that will help you navigate through the process:
Signing up for sandbox account
Signing up for a Sandbox account
Filling in details of your sandbox account
Filling in the details of your Sandbox account
Once done with entering the details for your Sandbox account, you'll need to check the email you provided in order to complete the registration. After that, you'll be able to login and start creating Sandbox PayPal accounts. Clicking onTest Accounts (menu on the left), and then Create Account: Preconfigured - will get you a form like the one on the image below:
Creating a Sandbox Test Account
Creating a Sandbox test account
Clarification of Account Type radio buttons: by selecting Buyer, you'll create a Personal account, and by selecting Seller, you'll create a Business account. For testing most integration scenarios, you'll need both accounts, so be sure to create them. Here is what you should eventually have on your screen after you click on Test Accounts:
Overview of your testing accounts
Overview of your testing accounts
Checking the radio button next to any of the accounts from the list and clicking on Enter Sandbox Test Site should bring up the Sandbox PayPal site which will allow you to login and administer your account in the same way as with a regular PayPal account. The only difference is that you'll have a huge PayPal Sandbox header and text that displays the email address of your developer account. To see what I'm talking about, check the image below:
Administering PayPal Sandbox account
Administering a PayPal Sandbox account
Last but not least - in order to use your Sandbox account for testing, you need to be logged in with your developer account. If you are not logged in and you follow some payment link, you'll get the following screen:
Login to use the PayPal Sandbox features
Login to use the PayPal Sandbox features




Website Payments Standard (HTML)

In this section, I'll provide you with a number of examples that will show how to create your own HTML form for receiving money over PayPal. You'll see how to use different variables in order to influence payment details. Before we delve into details, let's take a look at the two most basic variables:
  • form's action attribute - in most cases, it should be https://www.paypal.com/cgi-bin/webscr. If you are using Sandbox for testing payments, you'll change it to https://www.sandbox.paypal.com/cgi-bin/webscr - effectively, you just insert the word sandbox into the URL (this is also true for some other integrations; e.g., the PayPal API). For upcoming examples, I won't be using the Sandbox URL because most of you would just get that "Login to use the PayPal Sandbox features" screen (look up for the image).
  • form's business child - I'll use youremailaddress@yourdomain.com for most examples; if you copy-paste the code, you'll want to replace that with the email of your PayPal account.

Basic Payment

OK, let’s say you have an opened PayPal account and you just wish to be able to accept a $0.01 payment for a painting you are selling through your site. Just insert the following HTML into your page and you are set to go:

here is my source : 



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


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Paypal</title>
   
</head>
<body>
    <form id="paypalForm" method="post" action="<%Response.Write(URL);%>">
        <input type="hidden" name="cmd" value="<%Response.Write(cmd);%>" />
        <input type="hidden" name="business" value="<%Response.Write(business);%>" />
        <input type="hidden" name="item_name" value="<%Response.Write(item_name);%>" />
        <input type="hidden" name="amount" value="<%Response.Write(amount);%>" />
        <input type="hidden" name="no_shipping" value="<%Response.Write(no_shipping);%>" />
        <input type="hidden" name="return" value="<%Response.Write(return_url);%>" />
        <input type="hidden" name="rm" value="<%Response.Write(rm);%>" />
        <input type="hidden" name="notify_url" value="<%Response.Write(notify_url);%>" />
        <input type="hidden" name="cancel_return" value="<%Response.Write(cancel_url);%>" />
        <input type="hidden" name="currency_code" value="<%Response.Write(currency_code);%>" />
        <input type="hidden" name="custom" value="<%Response.Write(request_id);%>" />
     
    </form>
   <script language="javascript">
    document.forms["paypalForm"].submit ();
    </script>
   
</html>




here is my C# Code  : Here u need to send some important paramenters which is use for  Transaction.


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.VisualBasic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
public partial class Paypal : System.Web.UI.Page
{


    //"_notify-validate"
    protected string cmd = "_xclick";
    protected string business = "your-sandboxmailID@mail.com";
    protected string item_name = "Payment for Registration";
    protected string amount;
    protected string return_url = "http://yourwebURL/Paypal/Paypal.aspx";
    protected string notify_url = "http://yourwebURL/Paypal/Paypal.aspx";
    protected string cancel_url = "http://yourwebURL/Paypal/Paypal.aspx";
    protected string currency_code = "USD";
    protected string no_shipping = "1";
    protected string URL;
    protected string request_id;


    protected string rm;
    protected void Page_Load(object sender, EventArgs e)
 
{
 URL = "https://www.sandbox.paypal.com/cgi-bin/webscr";


 //This parameter determines the was information about successfull transaction will be          passed to the script
 // specified in the return_url parameter.
 // "1" - no parameters will be passed.
 // "2" - the POST method will be used.
 // "0" - the GET method will be used. 
 // The parameter is "0" by deault.
 rm = "2";


 // the total cost of the cart
 amount = 0.01;
 //Session("Amount")
 // the identifier of the payment request
 request_id = 1;
 //Session("request_id")
}
  
}


enjoy the code.