Clean WebForm

I need to clean a webform but I would like to field the field found a routine in C # you can convert to Cobol . Thank you

protected void Button1_Click(object sender, EventArgs e)

{

LimparControles(this.Page.Form.Controls);

}

public void LimparControles(ControlCollection controles)

{

foreach (Control controle in controles

{

if (controle.GetType() == typeof(TextBox))

((TextBox)controle).Text = string.Empty;

}

}

Translated by Google

Eu preciso limpar um webform mas não gostaria de fazer campo a campo encontrei uma rotina em c# é possível converter para Cobol. Obrigado.

  • Verified Answer

    Hi,

    This code should do it:-

          method-id Button1_Click protected.

          procedure division using by value lnkSender as object lnkEvent as type System.EventArgs.

              invoke self::EmptyControls(self::Page::Form::Controls)  

          end method.

          method-id EmptyControls private.

          local-storage section.

          01  myControl           type System.Web.UI.Control.

          01  myTextBox           type System.Web.UI.WebControls.TextBox.

          procedure division using by value lnkControls as type System.Web.UI.ControlCollection.

              perform varying myControl through lnkControls

                  if myControl is instance of type System.Web.UI.WebControls.TextBox

                      set myTextBox to myControl as type System.Web.UI.WebControls.TextBox

                      set myTextBox::Text to type System.String::Empty

                  end-if

              end-perform

          end method.

    Regards

    David

  • Verified Answer

    Thanks for answering , but this clearing of the master page information. I need to clean the form of a page called by the master page . Thank you!

    I made this work and invoke

    invoke self::EmptyControls(self::Page::Master::FindControl("MainContent")::Controls)

    Obrigado por responder, mas esta limpando as informações da master page. Preciso que limpe o form de uma página chamada pelo master page. Obrigado!

  • Verified Answer

    I made this work and invoque

              invoke self::EmptyControls(self::Page::Master::FindControl("MainContent")::Controls)