Link to home
Create AccountLog in
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMPFlag for United States of America

asked on

.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.
Avatar of guru_sami
Flag of United States of America image

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.
Avatar of Kyle Abrahams, PMP


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("'{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.
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account