Notes for hiding and displaying panel server controls in ASP. NET

Source: Internet
Author: User

In ASP. net, panel server controls are generally used as container controls to hide and display widgets in groups. In most cases, you can directly set the Panel's visualable attribute to true or false, however, in some cases, for example, when the entire page is validate, but in a hidden panel, there is the requiredvalidate control, which verifies that the control is hidden together with the Panel, therefore, it cannot pass the verification. Therefore, the page's validate cannot pass because of a validate control. The original intention is that hidden controls do not need to be verified.

To solve this problem, you need to find all the validate sub-controls in the Panel when hiding the panel, telling them that they can be ignored during the validate operation, and re-setting when displaying the panel.

This method consumes more resources than directly hiding or displaying the panel control. Therefore, you need to use it in different situations. If the Panel does not have a verification control, you can directly hide or display the panel control. If there is a verification control in the panel, it is best to use this article to hide or display it.

This sectionCodeUse the. NET Framework SDK sample duwamish directly.

' ----------------------------------------------------------------
' Sub showpanel:
' Helper sub used to make certain that the validators do not
' Fire when their parent panel is not visible.
' ----------------------------------------------------------------
Public   Shared   Sub showpanel () Sub Showpanel ( Byref Panel As Panel, Byval Visible As   Boolean )
Dim Validator As Ivalidator
Dim CTRL As Control

For   Each CTRL In Panel. Controls
' Check to see if its A validator
If   Typeof CTRL Is Ivalidator Then
Validator =   Ctype (CTRL, ivalidator)
CTRL. Visible = Visible
If   Not Visible Then
Validator. Validate ()
End   If
End   If
Next
Panel. Visible = Visible
End sub
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.