Good morning stackoverflow!
I have a little problem I'm trying to work out thats bugging the life out of me!
On my .aspx page i want to be able to show and hide certain panels depending on user selections (radiobuttonlists).
For example in my aspx page i have;
<form id="form1" runat="server">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:RadioButtonList>
<asp:Panel ID="Panel1" runat="server" Width="50%">
Visible or not visible depending on radio choice<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:Panel>
</form>
Then in my aspx.vb i have;
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If RadioButtonList1.SelectedItem.Equals(Nothing) Then
Panel1.Visible = False
Else
RadioButtonList1.SelectedItem.Equals(3)
Panel1.Visible = True
End If
End Sub
I've also tried a few different variants of this code, along with trying a select statement. If anyone could offer any advise on how to work this one out it greatly appreciate it
Thanks a lot, Phil
EDIT:
After further attempts and some reading on msdn I now have;
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Show or Hide the Panel contents.
If RadioButtonList1.SelectedItem.Equals(3) Then
Panel1.Visible = True
Else
Panel1.Visible = False
End If
End Sub
But when I try to run the code I get;
"Object reference not set to an instance of an object" on this line If RadioButtonList1.SelectedItem.Equals(3) Then