How to Do this on the Server Side in C# [Resolved]

Posted by Vuyiswamb under ASP.NET on 5/17/2011 | Points: 10 | Views : 4395 | Status : [Member] [MVP] [Administrator] | Replies : 1
Good Dal All

i have this aspx page

<%@ Page Language="C#" Async="true" Trace="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
<form runat="server" method="post" action="" >
<asp:HiddenField ID="p1" Value="4635" runat="server" />
<asp:HiddenField ID="p2" Value="2" runat="server" />
<asp:HiddenField ID="p3" Value="Some Goods" runat="server" />
<asp:HiddenField ID="p4" Value="5.00" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Pay by Credit Card"

what happens here is that on the Client side when someone clicks the Button it will do the payment and redirect to the page, i want to do this one the server side. i tried this

  protected void btnSubmit_Click1(object sender, EventArgs e)

string P1 = p1.Value;

string P2 = p2.Value;

string P3 = p3.Value;

String URl = "" + P1 + "&p2=" + P2 + "&p3=" + P3;
WebClient svc = new WebClient();
svc.UploadStringAsync(new Uri(""), "Post", "AT");
svc.UploadStringCompleted += new UploadStringCompletedEventHandler(svc_UploadStringCompleted);



void svc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
String estr = e.Result;

You can test using that URL


Thank you for posting at Dotnetfunda


Posted by: Vuyiswamb on: 6/13/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25


There is nothing wrong with the code, just that the payment gateway did not allow query-string embedded in their URL.

Thank you for posting at Dotnetfunda

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response