Print Page | Close Window

Select Case

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=4041
Printed Date: 28 March 2026 at 4:29pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Select Case
Posted By: ziwez0
Subject: Select Case
Date Posted: 03 July 2003 at 11:02am

Imhaving trouble trying to grasp a few things, but the problem im facing @ the moment is trying to display  a drop down menu on a select case
following code...

<script language="vb" runat="server">
Sub Page_Load()
  If Page.IsPostBack Then
    Select Case(number.SelectedItem.Value)
      Case "1":
        Message.Text = "<asp:dropdownlist id='list1' runat='server'>" & _
"<asp:listitem>7</asp:listitem>" & _
"<asp:listitem>8</asp:listitem>" & _
"<asp:listitem>9</asp:listitem>" & _
"</asp:dropdownlist>"
      Case "2":
        Message.Text = "hello2"
      Case "3":
        Message.Text = "hello 3"
      Case else
        Message.Text = "0000"
    End Select
  End If
End Sub
</script>

  <form runat="server">
  Select your choice:
  <br><br>
  <asp:radiobuttonlist id="number" runat="server">
    <asp:listitem>1</asp:listitem>
    <asp:listitem>2</asp:listitem>
    <asp:listitem>3</asp:listitem>
  </asp:radiobuttonlist>
  <br><br>
  <input type="submit" value="Submit Choice">
  <br><br>
  <asp:label id="message" runat="server"/>
</form>

the code works, but if you choose case 1 it does not display a drop down menu it will just write "789" any help with this matter would be a great help.



-------------
If anything takes long to do its worth doing.



Replies:
Posted By: MorningZ
Date Posted: 08 July 2003 at 12:19pm

the ASP engine does exactly as told to.. it fills the control "message" with a text value.... it has zero idea to "evaluate" it....

make another dropdownlist control with the values, and start it off as "Visible=False", and if it meets your criteria (first dropdown = 1), then switch visibility to "True"... otherwise fill in the text value of "message"



-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net