ok, you just need to move the line
Code:
Dim MyColorText as String
outside the Sub so that the variable is declared and available at the page level:
Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<script runat="server">
Sub Page_Load()
If NOT ispostback then
Dim ColorArray(4) as String
ColorArray(0) = "Blue"
ColorArray(1) = "Red"
ColorArray(2) = "Green"
ColorArray(3) = "Yellow"
ColorArray(4) = "Orange"
MyDropDownList.DataSource = ColorArray
MyDropDownList.DataBind()
End if
End Sub
Dim MyColorText as String
Sub ColorSelected(Source as Object, E as EventArgs)
MyColorText = MyDropDownList.SelectedItem.text
response.write (MyColorText)
End Sub
</script>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgColor="<%response.write(MyColorText)%>" >
<form runat="server">
<asp:dropdownlist ID="MyDropDownList" runat="server"></asp:dropdownlist>
<asp:button text="Hit Me" onCLick="ColorSelected" runat="server" />
</form>
</font>
</body>
</html>