asp.net - Submit a form and data after c# code has performed a function -


i've read lot of pages of questions , answers in regards form submitting in asp.net4.0 , fact ignores action="somepage.aspx" , posts only, none have touched on have issue:

i have form posts details hosted payment page (i.e. not on server) , data stored inside <input type="hidden" ... > controls, these controls data code behind, confirmation page , data previous page. till form works fine, posted data through external hosted page on clicking submit button. great.

now though need change <input type="submit" ... > button <asp:button ... > runs function in code behind log in database button clicked (it store click against users id) before posting data hosted page.

here problem lies, need 2 forms on page, 1 runat="server" overall page , it's asp.net controls, form , action="externalpage". gives following error

control 'submit' of type 'button' must placed inside form tag runat=server.

which impossible i'm beginning believe asp.net doesn't allow me want action="somepage". can't have both forms runat="server", can't not have second form , put

method="post" action="<%= m_szformaction %>"

inside overall form tag, doesn't know <%= m_szformaction %> is.

unfortunately, i'm stuck , appreciate / ideas how submit form data external hosted page, after updating database, using c# code behind.

for clarity here example code, 1st snippet worked ok originally, second need do:

<body>  <form id="form1" runat="server">   <asp:image id="image1"  runat="server" imageurl="images/logo.jpg" />  </form>  <form method="post" action="<%= m_szformaction %>">     <input type="hidden" name="merchantid" value="<%= m_szmerchantid %>" />     <input type="submit" class="btn" value="confirm booking" />  </form> </body> 

2nd snippet throws errors

<body>      <form id="form1" runat="server">       <asp:image id="image1"  runat="server" imageurl="images/logo.jpg" />      </form>      <form method="post" action="<%= m_szformaction %>">         <input type="hidden" name="merchantid" value="<%= m_szmerchantid %>" />         <asp:button id="submit" text="confirm" cssclass="btn"                  onclick="submit_click" runat="server"/>      </form>  </body> 

one workaround place hidden asp.net button in server form , virtually click when external button pressed

<body>   <form id="form1" runat="server">   <asp:image id="image1"  runat="server" imageurl="images/logo.jpg" />   <asp:button id="submit_homeserver" text="confirm" cssclass="btn"              onclick="submit_click" runat="server" style="visible:false;display:none"/>  </form>  <form method="post" action="<%= m_szformaction %>">     <input type="hidden" name="merchantid" value="<%= m_szmerchantid %>" />     <input type="submit" class="btn" value="confirm booking" onclick="javascript:document.getelementbyid("submit_homeserver").click()" />  </form> </body> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -