.Net Post form

Hi All,

I'm trying to update my hidden form items and then post to another page all in a single click.

So  I have a really simple form I have:
<input type="hidden" name="key" ID="key" runat="server" />

 and in a button click I do:
  key.Value = ConfigurationManager.AppSettings["Key"].ToString();

If I let the page come back and use another button with a postbackURL . . . the behavior works as expected.

If I try a response.Redirect the new value can't be read.
I cannot use a server.transfer as I'm going to a 3rd party site to submit the data.
I also tried the postback url on this button click as well, but that also can't be done.

So how do I update the value on the form and post it to another page?  Thanks in advnaced, been a long day and the brain is shot.
LVL 42
Kyle AbrahamsSenior .Net DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Response.Redirect won't work. You might want to try using other methods like saving in Session/ querystring parameter or cookie or db.
You can check CrossPage Posting.

You can access ConfigurationManager.AppSettings["Key"].ToString(); on other page as well. Not sure if you have is just an example or real code.
Kyle AbrahamsSenior .Net DeveloperAuthor Commented:
Hi Sami,

Unfortunately I'm going to an external 3rd party website for credit card processing, so accessing the variables in the other page is a no go (or I would have thrown it in the session or something).   I have this working where if the first button just formats the variables and the second one submits the form it's working, but I don't want to rely on the users clicking 2 buttons.  

My goal now is to combine the 2 button clicks.

<!-- sets the key and other pertinent info -->
<asp:Button runat="server" ID="btnSubmit" Text="Submit" onclick="btnSubmit_Click"    />

<!-- no code behind, just a redirect -->
<asp:Button runat="server" ID="btnTransfer3rdParty" Text="CC Proccessing" UseSubmitBehavior="true" PostBackUrl="GATEWAY URL" />

I've also tried from the btnSubmit but this also doesn't work.
            string script = string.Format("window.open('{0}');", "GATEWAY URL");
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "openSesame", script, true);

I need the values to be updated before going to the other page.
Kyle AbrahamsSenior .Net DeveloperAuthor Commented:
I ended up calling the click for the second button in the first:

  string script = @"$(document).ready(function () { $(""#" + btnTransfer3rdParty.ClientID + @""").click() } );";
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "openSesame", script, true);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kyle AbrahamsSenior .Net DeveloperAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.