Wednesday, March 21, 2012

Panels visible?

I have a page w/8 panels. Only panel I would like visible when the page is ran is Panel1. However when running the page both panels show up when the page runs. I have all of the Panels propertys set to false in HTML and here is the following code:


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()

Panel1.Visible = True
Panel2.Visible = False
Panel3.Visible = False
Panel4.Visible = False
Panel5.Visible = False
Panel6.Visible = False
Panel7.Visible = False
Panel8.Visible = False
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then

End If
End Sub

Private Sub btnNext1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext1.Click
If rbl1.SelectedValue = "Individual" Then
Panel1.Visible = False
Panel2.Visible = True
Panel3.Visible = False
Panel4.Visible = False
Panel5.Visible = False
Panel6.Visible = False
Panel7.Visible = False
Panel8.Visible = False
Else
Panel1.Visible = False
Panel2.Visible = False
Panel3.Visible = True
Panel4.Visible = False
Panel5.Visible = False
Panel6.Visible = False
Panel7.Visible = False
Panel8.Visible = False
End If
End Sub
End Class

Put the stuff in the Page_init into the Page_load and put it inside the following condition


if( ! Page.IsPostback )
{
Panel1.Visible = True
Panel2.Visible = False
Panel3.Visible = False
Panel4.Visible = False
Panel5.Visible = False
Panel6.Visible = False
Panel7.Visible = False
Panel8.Visible = False
}

else the code that displays #1 will be run every time the page loads... (you only need to give them the initial values, from here the event model and viewstate remembers the settings)

Dunno if this is what you mean!
oops...

A bit fast, didn't see you were using VB... But the example stands!

0 comments:

Post a Comment