Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3273502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:56:19+00:00 2026-05-17T18:56:19+00:00

I am posting values to from an ASP.NET website to a completely different site

  • 0

I am posting values to from an ASP.NET website to a completely different site (Paypal actually). I accomplish this by returning a page to the user that has all the hidden form inputs written and then a Javascript function that automatically submits the form.

The process is supposed to be seamless, but the blank page is noticeable for the couple seconds it shows up. Users are just supposed to click the button on the ASP.NET page, then be redirected to Paypal. But I inject this blank page in the middle to post the variables in the middle (variables like billing info, order items, etc). The blank page is too noticable and am hoping for either a better way of doing this or suggestions on making the process seem more seamless.

Here is the method I am using:

    public static void PostToRemote(string url, Dictionary<string, string> inputs)
    {
        if (String.IsNullOrEmpty(url))
            return;

        HttpContext context = HttpContext.Current;

        //CREATE UNIQUE FORM NAME
        string formName = "remoteform1";

        //ERASE ENTIRE RENDER OF CURRENT PAGE
        context.Response.Clear();

        //OUTPUT SINGLE FORM TO POST DATA
        context.Response.Write("<html><head></head>");

        //ON LOAD, PAGE WILL POST FORM TO NEW URL
        context.Response.Write(String.Format("<body onload=\"document.{0}.submit()\">", formName));
        context.Response.Write(String.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", formName, "post", url));

        //ADD PARAMETERS TO PAGE TO POST
        foreach (var item in inputs)
        {
            context.Response.Write(String.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", item.Key, item.Value));
        }

        context.Response.Write("</form>");
        context.Response.Write("</body></html>");

        context.Response.End();
    }

Any suggestions in making this more seamless or more enjoyable to the user? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:56:20+00:00Added an answer on May 17, 2026 at 6:56 pm

    What you can do is instead of writing the paypal form to the response stream, create a separate asp.net page and within that page write the paypal form info out with a asp.net repeater or similar control. Give the form that was written a name so that you can access it via javascript – for the purposes of this example well assume you named the form “paypal” (id=”paypal”). See below:

    Next put an image tag with an animated gif, some sort of progress spinner. Ok so now here is the important part: add a small javacript function to the page that will be responsible for posting the paypal form to the paypal server. See the following for an example:

    function submitform()
    {
        document.forms["paypal"].submit();
    }
    

    So now all you have to do is call this “submitform()” function from the body tag of the page like the following:

    <body onload="submitform()">
    

    So here is what the whole thing looks like.

    <!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>Untitled Page</title>
    </head>
    <body onload="submitform()">
        <div style="text-align: center;">
            <h1>
                Redirecting to PayPal</h1>
            <img src="http://www2.lionair.co.id/assets/imgs/ajax-loader.gif" />
        </div>
        <form id="form1" runat="server">
            <!--This is where you write out the paypal form data - use a repeater or create a custom control-->
        </form>
        <script type="text/javascript">
    function submitform()
    {
        document.forms["paypal"].submit();
    }
        </script>
    </body>
    </html>
    

    When you run this page the first thing that loads is the spinner image then the javascript posts the values to paypal giving you the effect your looking for.

    Hope this was helpful.

    Enjoy!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net HTTPHandler that gets POSTed from a ColdFusion web page whose
I am using asp.net's modelbinder functionality to bind form values to my entity when
Sorry for posting so many nubbin questions on ASP.net, I'm getting the hang of
After posting this question and reading that one I realized that it is very
I'm posting this in the spirit of answering your own questions. The question I
I found a posting on the MySQL forums from 2005 , but nothing more
I am looking at ASP.NET MVC2 and trying to post a complex object using
I've got a basic ASP.NET MVC 2 application. I've got adding and editing rows
I'm about to start a new ASP.NET MVC application. In it we have a
Just posting this here and might help the others: I got this error when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.