4

On my page I have toolbar which comes from Masterpage, and some input fields. All input fields are inside of tag form and toolbar outside tag form. Is it possible submit form after pressing on button outside of form tag?

Please suggest, Alexander.

Yaplex
  • 2,272
  • 1
  • 20
  • 38

3 Answers3

10

You can do it with JavaScript:

<input type="button" onclick="$('#someForm').submit();" />

The disadvantage, of course, is that it breaks without JavaScript.

I don't believe you can do what you ask without JavaScript, though.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
5

Use the OnClick-event of the button to submit the form, f.e.:

<INPUT TYPE=BUTTON OnClick="document.formname.submit();" VALUE="Submit">
0

I know this is old but what I recently did to solve this problem is the following:

I didn't submit the form per se because of other issues but I called a sub in the VB code and just referenced the text box.

<asp:Button ID="SubmitButton"
         runat="server"
         class="TextButton"
       onclick="SubmitButton_Click"
          Text="Submit" />

then from there called a nice little sub in the behind file

Partial Public Class SurveyQuestions
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

and then just a simple

Request("nameofcontrolhere")

and hey! Presto! It works without the use of a form, thereby allowing your button to be wherever you'd like.

Mankarse
  • 39,818
  • 11
  • 97
  • 141