Link to home
Start Free TrialLog in
Avatar of Ron Renninger
Ron Renninger

asked on

Post Form in asp.net in c#

Code is below

how do i combind the two buttons into one When i press get Token after getting the string i want to pass it to the form method post without an submit button. I looked into using javascript but do not see how that will work.

  <form runat="server">
         <asp:Button ID="GetToken" runat="server" Text="Get Token" OnClick="GetToken_Click" />


   </form>
   
    <form method="post" action="https://test.authorize.net/payment/payment"
id="formAuthorizeNetPage" >

       
        <input type="text" name="Token" value="<%=token%>" />
       
         <input type="submit" name="button" value="Buy now" />
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or give a unique id to button

<input type="submit" name="button" id="btnBuy" value="Buy now" />

then call

document.getElementById("btnBuy").click();

Open in new window


in GetToken_Click function...

are you using jQuery by the way?
Avatar of Ron Renninger
Ron Renninger

ASKER

it runs a class in c# and returns a value
so this, GetToken_Click, is a server side click?
if yes, then call whatever is needed when second form is submitted in this event...

or better move all logic into a new sub when 2nd form is submitted

page_load
  if page,ispostback {
    ProcessMain();
    ...
  }

Open in new window


and on GetToken_Click

GetToken_Click() {
  ... process click event
  ProcessMain();
}

Open in new window