twilitegxa 0 Newbie Poster

I have the follow script, and I would like to know how I can assign the values from my select options list to my class so that when the user selects an option from the color and gender option lists, that the suggested name is output to the user. I know I can do this instead with the label, but I need to know how to do it with the class and function. Right now it is just displaying the two words I have set for FirstName and LastName. Here what I have so far:

<script  runat="server">
sub Page_Load
if Not Page.IsPostBack then
            Dim petInformation = New SortedList
            petInformation.Add("A", "Select an option")
            petInformation.Add("R", "Red")
            petInformation.Add("B", "Blue")
            petInformation.Add("Y", "Yellow")
            petInformation.Add("G", "Green")
            petInformation.Add("L", "Black")
            petInformation.Add("W", "White")
            petInformation.Add("O", "Orange")
            petInformation.Add("P", "Pink")
            petInformation.Add("U", "Purple")
            dd.DataSource = petInformation
   dd.DataValueField="Key"
   dd.DataTextField="Value"
   dd.DataBind()
        End If
        If Not Page.IsPostBack Then
            Dim petInformation2 = New SortedList
            petInformation2.Add("Q", "Select an option")
            petInformation2.Add("X", "Female")
            petInformation2.Add("Z", "Male")
            dd2.DataSource = petInformation2
            dd2.DataValueField = "Key"
            dd2.DataTextField = "Value"
            dd2.DataBind()
        End If
end sub

   Sub displayMessage(ByVal s As Object, ByVal e As EventArgs)
        If dd.SelectedItem.Text = "Select an option" Then
            lbl1.Text = " "
        ElseIf dd.SelectedItem.Text = "Red" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Reese"
        ElseIf dd.SelectedItem.Text = "Red" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Bull"
        ElseIf dd.SelectedItem.Text = "Blue" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Raine"
        ElseIf dd.SelectedItem.Text = "Blue" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Ices"
        ElseIf dd.SelectedItem.Text = "Yellow" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Sunshine"
        ElseIf dd.SelectedItem.Text = "Yellow" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Blaze"
        ElseIf dd.SelectedItem.Text = "Green" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Sierra"
        ElseIf dd.SelectedItem.Text = "Green" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Forester"
        ElseIf dd.SelectedItem.Text = "Black" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Ebony"
        ElseIf dd.SelectedItem.Text = "Black" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Shadow"
        ElseIf dd.SelectedItem.Text = "White" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Serenity"
        ElseIf dd.SelectedItem.Text = "White" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Snowy"
        ElseIf dd.SelectedItem.Text = "Orange" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Caramel"
        ElseIf dd.SelectedItem.Text = "Orange" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Garfield"
        ElseIf dd.SelectedItem.Text = "Pink" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Princess"
        ElseIf dd.SelectedItem.Text = "Pink" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Arrow"
        ElseIf dd.SelectedItem.Text = "Purple" AndAlso dd2.SelectedItem.Text = "Female" Then
            lbl1.Text = "Dutchess"
        ElseIf dd.SelectedItem.Text = "Purple" AndAlso dd2.SelectedItem.Text = "Male" Then
            lbl1.Text = "Prince"
        End If
    End Sub
    
    'class
    Class PetName
        Public FirstName As String
        Public LastName As String
        
        Function GetName() As String
            Dim Whole As String
            Whole = FirstName & " " & LastName
            Return (Whole)
        End Function
    End Class
</script>
<html>
<head>
<title>PetName Class<title>
</head>
<body>
<p>Choose a color and gender below for a pet name suggestion:<br /><br />
<asp:DropDownList id="dd" runat="server"
AutoPostBack="True" />
<div align=left id=type_par><p><asp:label id="lbl1" runat="server" /></p>
<p align="center"><asp:DropDownList id="dd2" runat="server"
AutoPostBack="True" /><br />
 <%
        Dim Pet1 As PetName
        Pet1 = New PetName
        Pet1.FirstName = "Trinity"
        Pet1.LastName = "Smith"
 %>
<p>Suggested Pet Name: <%=Pet1.GetName%></p>
</body>
<html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.