How do I submit a form and then do a response.redirect?

Discussion in 'ASP .Net' started by Trevor Braun, Apr 17, 2006.

  1. Trevor Braun

    Trevor Braun Guest

    Hi all. I'm really stuck here, and would greatly appreciate any help or
    suggestions.

    I'm trying to (from the server side) submit the page that is loading to a
    new window, then redirect to another form.

    What I'm trying to do would look like:

    protected void Page_Load(object sender, EventArgs e)
    {
    form1.hiddenField1.Value = Request["ccvalue1"];
    form1.hiddenField2.Value = Request["ccvalue2"];

    form1.Target="_blank";
    form1.Submit();

    Response.Redirect("default.aspx");
    }

    The reason I'm doing this is because ASP.NET changes the ID's of hidden
    fields that belong to a page with a master template, and I need to submit to
    a credit card pay page that is expecting specially named hidden form fields.
    This page is a dummy page (without a master template page) that receives
    values from an order wizard then loads the values into the hidden fields on
    the dummy page's load and submits itself to the credit card pay page in a
    new window and then redirects itself to "default.aspx", the user's home
    page.


    Thanks again for any suggestions.
    Trevor Braun
    Trevor Braun, Apr 17, 2006
    #1
    1. Advertising

  2. Trevor Braun

    Neutrino Guest

    The strategy you are trying to implement would work but i might suggest
    that you take a look at the HttpWebRequest class (net framework
    System.Net). With an object of this class you can call the credit card
    page submitting all the fields you need (with POST method) and get the
    output returned by the credit card page. You would be able to do this
    within the same page in your application (without the need of opening
    another browser window).

    You can find more information here:

    http://www.netomatix.com/HttpPostData.aspx

    and here

    http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest(VS.80).aspx

    Regards
    Neutrino, Apr 17, 2006
    #2
    1. Advertising

  3. Trevor Braun

    Neutrino Guest

    The strategy you are trying to implement would work but i might suggest
    that you take a look at the HttpWebRequest class (net framework
    System.Net). With an object of this class you can call the credit card
    page submitting all the fields you need (with POST method) and get the
    output returned by the credit card page. You would be able to do this
    within the same page in your application (without the need of opening
    another browser window).

    You can find more information here:

    http://www.netomatix.com/HttpPostData.aspx

    and here

    http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest(VS.80).aspx

    Regards
    Neutrino, Apr 17, 2006
    #3
  4. Trevor Braun

    Trevor Braun Guest

    Thanks. That sounds like an excellent solution, but I don't know if will
    fit what I need to do. The credit card information actually gets entered
    into the new window, the only thing I submit to the pay page are three
    hidden fields (two identify the company, the third holds the amount to be
    charged to the card.)

    I'll play around with it and see if I can't get something working.

    Trevor Braun


    "Neutrino" <> wrote in message
    news:...
    > The strategy you are trying to implement would work but i might suggest
    > that you take a look at the HttpWebRequest class (net framework
    > System.Net). With an object of this class you can call the credit card
    > page submitting all the fields you need (with POST method) and get the
    > output returned by the credit card page. You would be able to do this
    > within the same page in your application (without the need of opening
    > another browser window).
    >
    > You can find more information here:
    >
    > http://www.netomatix.com/HttpPostData.aspx
    >
    > and here
    >
    > http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest(VS.80).aspx
    >
    > Regards
    >
    Trevor Braun, Apr 17, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sal
    Replies:
    1
    Views:
    380
  2. Replies:
    0
    Views:
    261
  3. Dima67
    Replies:
    1
    Views:
    960
    Bob Barrows
    Aug 28, 2009
  4. Paul Oakfleet
    Replies:
    1
    Views:
    836
    Chris Riesbeck
    Sep 10, 2003
  5. Replies:
    3
    Views:
    654
Loading...

Share This Page