-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SitaramanM
Message 12 in Discussion

Hi Bhavtosh   For a implementaion of ur reqmt without the use of panels.  Check out 
the code attached.  It is a Simple Web Page using three Web User 
Controls(WebUserControl1 is redundant and can be ignored).  I have one instance of 
WebUserControl2 and 4 instances of WebUserControl3.  In the Click of a button from 
WebUserControl2 Im hiding allk the instances of WebUserControl3 here. Sample Code is 
as follows   Public MustInherit Class WebUserControl2
    Inherits System.Web.UI.UserControl
    Protected WithEvents btn_HideWebUserControl3 As System.Web.UI.WebControls.Button
    Protected WithEvents btn_ShowWebUserControl3 As System.Web.UI.WebControls.Button   
#Region " Web Form Designer Generated Code "     'This call is required by the Web 
Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()     
End Sub       Private Sub Page_Init(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub #End Region       Private Sub Page_Load(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub       Private Sub btn_HideWebUserControl3_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles btn_HideWebUserControl3.Click
        ToggleControlVisibility(False)     End Sub       Private Sub 
btn_ShowWebUserControl3_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles btn_ShowWebUserControl3.Click
        ToggleControlVisibility(True)
    End Sub       Private Sub ToggleControlVisibility(ByVal p_blnVisible As Boolean)
        Try
            Dim l_objPropertiesInfo() As PropertyInfo
            Dim l_objPropertyInfo As PropertyInfo
        l_objPropertiesInfo = Me.Page.GetType.GetProperties(BindingFlags.NonPublic Or 
BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.Static)
        For Each l_objPropertyInfo In l_objPropertiesInfo
            If l_objPropertyInfo.PropertyType.ToString.EndsWith("WebUserControl3") 
Then ' Checking the Type of the Control here
                Dim l_objControl As Control = 
Me.Page.FindControl(l_objPropertyInfo.Name)
                l_objControl.Visible = p_blnVisible
            End If
            Next
        Catch p_objException As Exception
            Debug.WriteLine("Error : " & p_objException.Message)
        End Try
    End Sub   Uses a bit of Reflection of course.  If you dont want to hide all 
instances of the UserControl3 and only specific instances, Then you can create a sort 
of array in the page which will contain the names of the instances which u want to be 
hidden and pass each element of the array to the GetProperty Function inside the 
ToggleControlVisibility() function instead of using the GetProperties.     Have Tested 
the Code and it works without any problems. Also attached is a complete solution of 
the same in VS.Net format...  Do Get back in case of any problems   hth     regards,   
sr
View Attachment(s):
http://groups.msn.com/BDotNet/_notifications.msnw?type=msg&parent=1&item=5313
-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to