Do not hide div when performing function

Asked

Viewed 68 times

1

Hi, I’m doing a college project where I have to use web Forms. By default in my project I have a div that is None by default in css, and within this div is a small form, as follows the example:

NOTE: I forgot to mention that this form is opened through a button, which using javascript makes the same display change: None, for display: inline-block.

 <div class="x_panel" id="div1">
          <div class="x_title">
            <h2>Cerâmicas X <small>cadastro de produto</small></h2>
            <div class="clearfix"></div>
          </div>
          <div class="x_content">
            <br/>
            <form class="form-horizontal form-label-left input_mask">

              <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback">
                <asp:TextBox ID="txt_prod_modelo" runat="server"  class="form-control has-feedback-left" Text="Modelo do produto"></asp:TextBox>
                <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
              </div>

              <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback">
                <asp:TextBox ID="txt_prod_quantidade" runat="server"  class="form-control has-feedback-left" Text="Quantidade de produto"></asp:TextBox>   
                <span class="fa fa-user form-control-feedback right" aria-hidden="true"></span>
              </div>
                <asp:Label ID="msg" runat="server" Text="Label" ></asp:Label>

               <asp:Button ID="Button1" runat="server" Text="Button" Onclick="Cadastrarproduto_Click"  />

          </form>
          </div>

   </div>

Well, when I click the button, it executes the method Register product through the onclick, and this onclick gives a Reload on the page, making the form again None. I tried to create a javascript function and put inside the button in an Onclientclick but it also did not work. I don’t know if I could express myself very well, but I would like help so that either this Reload does not occur or to be able to display my div again. Thank you for your attention and help.

  • Are you saying that when you click on Button1, to register the product, it is giving Reload on the page and you would like it not to do that? Register the product and remain with the open form?

  • exactly! when Onclick runs an auto-load page and div goes back to None

  • Have you ever tried to register for Ajax, for example? Otherwise, you could send some parameter of code Behind pro webform and check to show or not...

  • With Onclientclick did not work?

  • I will try to perform by ajax, researched some similar questions and recommended the same. I will give a better search here. Thank you

1 answer

0


In case someone has the same problem, I solved it this way:

 <asp:ScriptManager runat="server" ID="sm">
                </asp:ScriptManager>
                <asp:updatepanel runat="server">
                 <ContentTemplate>

                //conteudo a ser controlado aqui.

                </ContentTemplate>
                </asp:updatepanel>

Browser other questions tagged

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