Highlighted
Super Contributor.
Super Contributor.
1166 views

Clean WebForm

Jump to solution

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.

0 Likes
3 Solutions

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Clean WebForm

Jump to solution

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

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Clean WebForm

Jump to solution

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!

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Clean WebForm

Jump to solution

I made this work and invoque

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

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: Clean WebForm

Jump to solution

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

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Clean WebForm

Jump to solution

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!

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Clean WebForm

Jump to solution

I made this work and invoque

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

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.