Do not show controls when you identify that page! IsPostBack in c #

0

I need to hide the controls of a form that I intend to use to create credit requests.

the procedure to be performed is: If the page is displayed for the first time, the controls to add client and co-debtor information are displayed, stored when editing, the payment agreement and initial date controls should be displayed.

try to do it in the following way:

I declare the method

public void deshabilitarcontroles(){
    TextBoxValor_Credito.Visible = false;
    DropDownListPeriodo_cre.Visible = false;
    TextBoxCuotas.Visible = false;
    TextBoxFechainicial1.Visible = false;
    TextBoxFechainicial2.Visible = false;
    TextBoxValorcuotainicial1.Visible = false;
    TextBoxValorcuotainicial2.Visible = false;
}

if (!IsPostBack) { 
    deshabilitarcontroles();
}

But I see that it disables only the fields to store the data, it does not disable the full text box.

How could I do it? So it appears to me

if the page is for the first time they should not appear

Thank you in advance, greetings!

    
asked by Andrex_11 10.05.2018 в 18:03
source

2 answers

1

was simple, what you can do to hide the entire row was to add an ID to <tr> ie:

<tr id="nivel2">
  ...//Estructura
<tr>

and in the method indicate that this control is visible or hidden from that id

public void deshabilitarcontroles(){
   nivel2.Visible = false;
}

and apply the condition as it was

if (!IsPostBack) { 
    deshabilitarcontroles();
}
    
answered by 19.09.2018 / 18:59
source
1

What you can do to place block or put invisible. What I do to add a void that I will enter a Bool if it is true is to say that it will appear and if it is false that everything will not be seen.

I hope I have helped you.

   protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
                { 
                 visible(false)
                 }
    }


     void visible(Boolean blo)
            {
    TextBoxValor_Credito.Visible = blo;
                DropDownListPeriodo_cre.Visible = blo;
                TextBoxCuotas.Visible = blo;
                TextBoxFechainicial1.Visible = blo;
                TextBoxFechainicial2.Visible = blo;
                TextBoxValorcuotainicial1.Visible = blo;
                TextBoxValorcuotainicial2.Visible = blo;


    }
    
answered by 11.05.2018 в 01:38