2
I have two tags form on a page to validate some fields that appear in the modal, the first form
, is only to search on grid
. The button
to open the modal, and to remove the filter work perfectly.
However, when opening the modal, the buton
that sends the data does not work, it just closes the modal. And if I put it (the button) inside the tag form
, he (the form
) error as if it had not filled in.
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="row">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<div id="contact-form" class="panel panel-default">
<div style="text-align: center;" class="panel-heading">
<p class="panel-title">
<asp:Label ID="Label78" runat="server" Font-Size="Large" Text="Agendar Avaliação Física"></asp:Label>
</p>
</div>
<form id="form">
<div class="row">
<div class="modal-body">
<div class="col-md-2">
<asp:Label ID="Label18" runat="server" Text="Hora"></asp:Label>
</div>
<div class="col-md-3">
<div class="input-group">
<asp:TextBox ID="txtHora" runat="server" class="form-control" required="required" onblur="Verifica_Hora(this);"></asp:TextBox>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-asterisk"></span></span>
</div>
</div>
<div class="col-md-1">
<asp:Label ID="Label250" runat="server" Text="Data"></asp:Label>
</div>
<div class="col-md-4">
<div class="input-group">
<asp:TextBox ID="txtData" runat="server" class="form-control" onblur="limparDataInvalida(this);" required="required"></asp:TextBox>
<span class="input-group-addon danger"><span class="glyphicon glyphicon-asterisk"></span></span>
</div>
</div>
<div class="col-md-2">
<asp:Label ID="Label19" runat="server" Text="Observação"></asp:Label>
</div>
<div class="col-md-9">
<textarea id="txtObeservacao" cols="20" rows="2" runat="server" class="form-control" style="resize: none"></textarea>
</div>
</div>
</div>
</form>
<div class="modal-footer">
<asp:Button ID="btnGravar" runat="server" CssClass="btn btn-success btn-block" Text="Gravar" OnClick="btnGravar_Click" />
</div>
</div>
</div>
</div>
<br />
</div>
</div>
</div>
It should save, in the code I save the data in the database or change, how I can make it work?
That is
asp.net
webforms
, Correct? You speak of 2 Forms, but you only show one of them, but what is wrong when trying to save, as you said is the first form. I understood correctly?– Diego Rafael Souza
It is this, the other form, the Buttons are only for consultation, and the queries are performed correctly, including the button to open the modal, is within the first form, this is the second. This is the button that has the function saving the fields in onclick, but it does not work <Asp:Button ID="btnGravar" runat="server" Cssclass="btn btn-Success btn-block" Text="Record" Onclick="btnGravar_Click" />
– Mariana
So is there some mistake in the
btnGravar_Click
. You tried to see if any error is being fired there?– Diego Rafael Souza
Yes, if it is inside the form, it appears as if the fields have not filled in, even if it is filled in, and when it is outside that form, it does nothing.
– Mariana
The
runat="server"
in your form, content you should not have more than one<form>
per page in Webforms. the ideal would be for you to transpose your modal to a Usercontrol (.ascx)– Leandro Angelo
When I put the runat="server" in the form I need to save the data to the database, it returns me the following error 'Page can only have a server Form tag.'
– Mariana
@Leandroangelo has some example that can help me ?
– Mariana
@marianac_costa if no one answers before, at night I leave an example as answer
– Leandro Angelo
Able to solve @Leandroangelo thanks.
– Mariana
@marianac_costa It would be nice for you to post your solution as an answer or remove the question, but I advise the first option as this will help other people who come to face the same problem.
– Leandro Angelo