code behind
==========================
string strPostURL = string.Empty;
if (ConfigurationManager.AppSettings["IsLive"].ToLower() == "L".ToLower())
{
strPostURL = ConstantValue.Liveurl;
}
else
{
strPostURL = ConstantValue.TestUrl;
}
PayPalTran obj = new PayPalTran();
Hashtable hs = new Hashtable();
hs = obj.GetHashTableForPaypal();
//Add parameters on from
HtmlInputHidden hiddenInputControl = new HtmlInputHidden();
System.Web.UI.HtmlControls.HtmlForm oForm = new System.Web.UI.HtmlControls.HtmlForm();
oForm.Attributes.Add("action", strPostURL);
oForm.Attributes.Add("method", "post");
IDictionaryEnumerator en = hs.GetEnumerator();
while (en.MoveNext())
{
hiddenInputControl = new HtmlInputHidden();
hiddenInputControl.Name = en.Key.ToString();
hiddenInputControl.ID = en.Key.ToString();
hiddenInputControl.Value = en.Value.ToString();
oForm.Controls.Add(hiddenInputControl);
}
hiddenInputControl = new HtmlInputHidden();
hiddenInputControl.Name = "notify_url";
hiddenInputControl.ID = "notify_url";
hiddenInputControl.Value = clsComman.SecureUrl + "PayPalno_url.aspx";
oForm.Controls.Add(hiddenInputControl);
bodydPay.Controls.Add(oForm);
if (Session["PTran"] != null)
{
Page.RegisterStartupScript("a0", Session["PTran"].ToString());
}
Page.RegisterStartupScript("a1", "<script>document.forms[0].action = '" + strPostURL + "';</script>");
Page.RegisterStartupScript("a2", "<script>document.forms[0].submit();</script>");
}
}
+++++++++++++++++
aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PayPal.aspx.cs" Inherits="PayPalPost" %>
<!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> CheckOut</title>
<style type="text/css">
body
{
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #111B07;
margin: 0 auto;
}
</style>
</head>
<body id="bodydPay" runat="server">
<div style="width: 100%; height: 100%; text-align: center;">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<img src="Images/Load.gif" />
<p style="color: green;">
<b>You are redirecting to the PayPal.....</b></p>
<p style="color: Red;">
<b>PayPal can take some time, please be patient while your contract goes through.</b></p>
</div>
</body>
</html>