How to treat multiple Forms on the same page.aspx?

Asked

Viewed 1,570 times

1

I have a.aspx page that I have several Forms. One of the Forms put runat="server" and you’re like Textbox, I was able to take the form data and insert it into the database. But I wanted to do the same with the other forms, but I don’t know how to do that. Yeah, can’t have more than one form server="runat" on the same page.

How do I receive data from other Forms in my class?

Follow the codes of my forms:

<!-- Modal Veículos -->
    <div id="myModal_Veiculos" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <form id="Cad_Veiculos">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3>Cadasto de Clientes</h3>
        </div>
        <div class="modal-body">
                <label>Placa </label><input type="text" id="placa" name="placa" />
                <label>Quilometragem </label><input type="text" id="quilometragem" name="quilometragem" />
                <label>Cor </label><input type="text" name="cor" id="cor" />
                <label>Tipo </label><input type="text" name="tipo" id="tipo" />
                <label>Ano </label><input type="text" name="ano" id="ano" />
                <label>Chassi </label><input type="text" name="chassi" id="chassi" />
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Fechar</button>
            <Button class="btn btn-primary"onclick="button1_cad_cliente">Salvar</Button>
        </div>
        </form>
    </div>


    <!-- Modal Clientes -->
    <div id="myModal_Clientes" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
        <form id="clientes" runat="server">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3>Cadasto de Clientes</h3>
        </div>
        <div class="modal-body">
                <label>Nome </label><asp:TextBox id="nome_clientes" runat="server"></asp:TextBox>
                <label>CPF </label><asp:TextBox id="cpf_clientes" runat="server"></asp:TextBox>
                <label>RG </label><asp:TextBox id="rg" runat="server"></asp:TextBox>
                <label>Endereço </label><asp:TextBox id="endereco" runat="server"></asp:TextBox>
                <label>Telefone </label><asp:TextBox id="telefone" runat="server"></asp:TextBox>
                <label>E-mail </label><asp:TextBox id="email_clientes" runat="server"></asp:TextBox>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Fechar</button>
            <asp:Button class="btn btn-primary" Text="Salvar" runat="server" onclick="button1_cad_cliente"></asp:Button>
        </div>
        </form>

    </div>
  • Friend, your question contains typos is runat="server", and then how will a form be of the Textbox type? Unless it is A <form> field... Finally checks and...

  • But the Texbox, if you look closely, is wrapped in a form.

  • Yes, that’s seen, is that you had said it incorrectly!

  • The link you sent is similar to my doubt. But it was not enough to remove my doubt. But it was worth.

  • Take a look again... I did an update.!

1 answer

1

Dude, take a look at my comment too, but to answer your question is simple!

Take a look at this link, that will cure your doubts!

Valeuu! D

UPDATE 01

You must set an action and method in the form that does not have runat="server", because Asp net does not allow two Forms with runat="server", operating on the same page.

I suggest you analyze your structure and create a Webusercontrol, or move one of these forms to another aspx page. And it is not possible to recover on the same page the values of these two Forms! :D

Got it?!

  • I understood yes. I will try and soon get in touch with you.

  • Is there an example of how to recover Asp.net pages for my main page? I have this problem because I’m new to C# webforms.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.