Christopher Kile
asked on
Using WebControls.DropDownList, my SelectedIndexChanged handler never fires, though other handlers do fire
In the following code (I include the .ASPX followed by the code-behind ASPX.VB), it can be seen that I set up the handler for OnSelectedIndexChanged for listENV, but no matter what item I choose on the list, listENV_IndexChange() is never executed, though txtDatabaseNum_TextChanged (), btnCancel_Click(), and btnSave_Click() are all executed when their respective events are fired (also, when I write AddHandler and use Intellisense to tell me what objects have events that might have handlers added for them, listEnv does not appear in the list, though all the text controls do):
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx. vb" Inherits="DB_Status.WebFor m1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScri pt" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body bgColor="whitesmoke" MS_POSITIONING="GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:button id="btnCancelTop" style="Z-INDEX: 108; LEFT: 24px; POSITION: absolute; TOP: 16px"
OnClick="btnCancel_Click" runat="server" Width="168px" Height="25px" Text="Cancel and Return to Menu"
CausesValidation="True"></ asp:button >
<asp:button id="btnSaveTop" style="Z-INDEX: 119; LEFT: 208px; POSITION: absolute; TOP: 16px"
OnClick="btnSave_Click" runat="server" Width="160px" Height="25px" Text="Save and Return to Menu"
CausesValidation="True"></ asp:button >
<asp:button id="btnCancelBottom" style="Z-INDEX: 106; LEFT: 24px; POSITION: absolute; TOP: 480px"
OnClick="btnCancel_Click" runat="server" Width="168px" Height="25px" Text="Cancel and Return to Menu"></asp:button>
<asp:button id="btnSaveBottom" style="Z-INDEX: 107; LEFT: 208px; POSITION: absolute; TOP: 480px"
OnClick="btnSave_Click" runat="server" Width="160px" Height="25px" Text="Save and Return to Menu"></asp:button>
<asp:label id="lblENV" style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 88px" runat="server"
Width="152px" Height="8px" Font-Bold="True" ForeColor="#0033FF">Enviro nment:</as p:label>
<asp:dropdownlist
id="listENV"
style="Z-INDEX: 101; LEFT: 192px; POSITION: absolute; TOP: 88px"
runat="server"
OnSelectedIndexChanged="li stENV_Inde xChange"
AutoPostBack="True"
Width="108px"
Height="40px"
Enabled="True"
EnableViewState="True"
Visible="True"></asp:dropd ownlist>
<asp:requiredfieldvalidato r id="reqENV" style="Z-INDEX: 115; LEFT: 344px; POSITION: absolute; TOP: 88px" runat="server"
Width="16px" Height="8px" ErrorMessage="RequiredFiel dValidator " ControlToValidate="listEnv "></asp:re quiredfiel dvalidator >
<asp:label id="lblDatabaseNum" style="Z-INDEX: 104; LEFT: 25px; POSITION: absolute; TOP: 120px"
runat="server" Width="152px" Height="10px" Font-Bold="True" ForeColor="#0033FF">Databa se #:</asp:label>
<asp:textbox id="txtDatabaseNum" style="Z-INDEX: 102; LEFT: 192px; POSITION: absolute; TOP: 120px"
OnTextChanged="txtDatabase Num_TextCh anged" runat="server" Width="105px" Height="21px" AutoPostBack="True"></asp: textbox>
<asp:requiredfieldvalidato r id="reqDatabaseNum" style="Z-INDEX: 114; LEFT: 344px; POSITION: absolute; TOP: 120px"
runat="server" Width="16px" Height="8px" ErrorMessage="RequiredFiel dValidator " ControlToValidate="txtData baseNum">< /asp:requi redfieldva lidator>
<asp:label id="lblSoftwareTree" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 155px"
runat="server" Width="152px" Height="10px" Font-Bold="True" ForeColor="#0033FF">Sofwar e Tree:</asp:label>
<asp:textbox id="txtSoftwareTree" style="Z-INDEX: 109; LEFT: 192px; POSITION: absolute; TOP: 152px"
runat="server" Width="105px" Height="22px" MaxLength="3" AutoPostBack="True"></asp: textbox>
<asp:requiredfieldvalidato r id="reqSoftwareTree" style="Z-INDEX: 116; LEFT: 344px; POSITION: absolute; TOP: 155px"
runat="server" Width="8px" Height="8px" ErrorMessage="RequiredFiel dValidator " ControlToValidate="txtSoft wareTree"> </asp:requ iredfieldv alidator>
<asp:label id="lblActive" style="Z-INDEX: 112; LEFT: 24px; POSITION: absolute; TOP: 192px"
runat="server" Width="152px" Height="8px" Font-Bold="True" ForeColor="Blue">Database is active:</asp:label>
<asp:checkbox id="chkActive" style="Z-INDEX: 110; LEFT: 192px; POSITION: absolute; TOP: 192px"
runat="server" Width="104px" Height="24px" AutoPostBack="True"></asp: checkbox>
<asp:table id="tblPrimeTimeEntry" style="Z-INDEX: 111; LEFT: 24px; POSITION: absolute; TOP: 288px"
runat="server" Width="50%" BorderColor="Black" BorderStyle="Solid">
<asp:TableRow>
<asp:TableCell>
Monday thru Friday
</asp:TableCell>
<asp:TableCell>
<input name="hh_mon_fri_start" type="text" value="07" maxlength="2" id="hh_mon_fri_start"
runat="server" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_mon_fri_start" type="text" value="00" maxlength="2" id="mm_mon_fri_start"
runat="server" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_mon_fri_end" type="text" value="19" maxlength="2" id="hh_mon_fri_end" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_mon_fri_end" type="text" value="00" maxlength="2" id="mm_mon_fri_end" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
Saturday
</asp:TableCell>
<asp:TableCell>
<input name="hh_sat_start" type="text" value="00" maxlength="2" id="hh_sat_start" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_sat_start" type="text" value="00" maxlength="2" id="mm_sat_start" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_sat_end" type="text" value="00" maxlength="2" id="hh_sat_end" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_sat_end" type="text" value="00" maxlength="2" id="mm_sat_end" runat="server"
style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
Sunday
</asp:TableCell>
<asp:TableCell>
<input name="hh_sun_start" type="text" value="00" maxlength="2" id="hh_sun_start" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_sun_start" type="text" value="00" maxlength="2" id="mm_sun_start" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_sun_end" type="text" value="00" maxlength="2" id="hh_sun_end" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
:
<input name="mm_sun_end" type="text" value="00" maxlength="2" id="mm_sun_end" style="color:Black;backgro und-color: Yellow;wid th:40%;" />
</asp:TableCell>
</asp:TableRow>
</asp:table>
<asp:validationsummary id="vsAddDB" style="Z-INDEX: 113; LEFT: 384px; POSITION: absolute; TOP: 64px" runat="server"
Width="256px" Height="264px"></asp:valid ationsumma ry><asp:la bel id="lblPermittedNodes" style="Z-INDEX: 117; LEFT: 24px; POSITION: absolute; TOP: 232px"
runat="server" Width="152px" Height="8px" Font-Bold="True" ForeColor="Blue" Enabled="False">Permitted Nodes for Execution:</asp:label><asp :dropdownl ist id="dlstPermittedNodes" style="Z-INDEX: 118; LEFT: 192px; POSITION: absolute; TOP: 232px"
runat="server" Width="169px" Height="16px" AutoPostBack="True" Enabled="False"></asp:drop downlist>
</form>
</body>
</HTML>
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
End Sub
Protected hh_mon_fri_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_mon_fri_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected hh_mon_fri_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_mon_fri_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected hh_sat_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_sat_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected hh_sat_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_sat_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected hh_sun_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_sun_start As System.Web.UI.HtmlControls .HtmlInput Text
Protected hh_sun_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected mm_sun_end As System.Web.UI.HtmlControls .HtmlInput Text
Protected WithEvents btnCancelTop As System.Web.UI.WebControls. Button
Protected WithEvents btnSaveTop As System.Web.UI.WebControls. Button
Protected WithEvents btnCancelBottom As System.Web.UI.WebControls. Button
Protected WithEvents btnSaveBottom As System.Web.UI.WebControls. Button
Protected WithEvents lblENV As System.Web.UI.WebControls. Label
Protected WithEvents listENV As System.Web.UI.WebControls. DropDownLi st
Protected WithEvents reqENV As System.Web.UI.WebControls. RequiredFi eldValidat or
Protected WithEvents lblDatabaseNum As System.Web.UI.WebControls. Label
Protected WithEvents txtDatabaseNum As System.Web.UI.WebControls. TextBox
Protected WithEvents reqDatabaseNum As System.Web.UI.WebControls. RequiredFi eldValidat or
Protected WithEvents lblSoftwareTree As System.Web.UI.WebControls. Label
Protected WithEvents txtSoftwareTree As System.Web.UI.WebControls. TextBox
Protected WithEvents reqSoftwareTree As System.Web.UI.WebControls. RequiredFi eldValidat or
Protected WithEvents lblActive As System.Web.UI.WebControls. Label
Protected WithEvents chkActive As System.Web.UI.WebControls. CheckBox
Protected WithEvents tblPrimeTimeEntry As System.Web.UI.WebControls. Table
Protected WithEvents vsAddDB As System.Web.UI.WebControls. Validation Summary
Protected WithEvents lblPermittedNodes As System.Web.UI.WebControls. Label
Protected WithEvents dlstPermittedNodes As System.Web.UI.WebControls. DropDownLi st
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara tion As System.Object
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()
End Sub
#End Region
Private m_adb As AvailabilityDBaccess
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim i As Integer
Dim evl As System.Diagnostics.EventLo g
Dim hshArray() As Hashtable
If Not IsPostBack Then
Response.Cache.SetExpires( DateTime.N ow)
Response.Cache.SetCacheabi lity(HttpC acheabilit y.NoCache)
Response.Cache.SetValidUnt ilExpires( True)
evl = New System.Diagnostics.EventLo g
If Not evl.SourceExists("SBODispl ayStatus") Then
evl.CreateEventSource("SBO DisplaySta tus", "Application")
End If
evl.Source = "SBODisplayStatus"
m_adb = New AvailabilityDBaccess(evl, False, Request.PhysicalApplicatio nPath)
Session("adb") = m_adb
hshArray = m_adb.getAllEnvironments()
listENV.Items.Clear()
listENV.Items.Add("")
listENV.Items(0).Value = 0
For i = 0 To hshArray.Length - 1
listENV.Items.Add(hshArray (i)("env_n ame"))
listENV.Items(i).Value = CType(hshArray(i)("env_id" ), Int32)
Next
Else
'm_adb = Session("adb")
End If
End Sub
Protected Sub listENV_IndexChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listENV.SelectedIndexChang ed
ViewState("listENVSelected Index") = listENV.SelectedIndex
If listENV.SelectedIndex < 1 Then
ViewState("env_name") = ""
Else
ViewState("env_name") = listENV.SelectedItem.Text
End If
End Sub
Protected Sub txtDatabaseNum_TextChanged (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDatabaseNum.TextChanged
Dim env_name As String
Dim database_num As String
Dim hsh As Hashtable
listENV.SelectedIndex = ViewState("listENVSelected Index")
env_name = ViewState("env_name")
database_num = Trim(txtDatabaseNum.Text)
hsh = m_adb.getDatabaseSetupByEn vNameDBNum (env_name, database_num)
chkActive.Checked = hsh("active") <> 0
hh_mon_fri_start.Value = Format(CDate(hsh("hh_mon_f ri_start") ), "HH")
hh_mon_fri_end.Value = Format(CDate(hsh("hh_mon_f ri_end")), "HH")
hh_sat_start.Value = Format(CDate(hsh("hh_sat_s tart")), "HH")
hh_sat_end.Value = Format(CDate(hsh("hh_sat_e nd")), "HH")
hh_sun_start.Value = Format(CDate(hsh("hh_sun_s tart")), "HH")
hh_sun_end.Value = Format(CDate(hsh("hh_sun_e nd")), "HH")
mm_mon_fri_start.Value = Format(CDate(hsh("mm_mon_f ri_start") ), "mm")
mm_mon_fri_end.Value = Format(CDate(hsh("mm_mon_f ri_end")), "mm")
mm_sat_start.Value = Format(CDate(hsh("mm_sat_s tart")), "mm")
mm_sat_end.Value = Format(CDate(hsh("mm_sat_e nd")), "mm")
mm_sun_start.Value = Format(CDate(hsh("mm_sun_s tart")), "mm")
mm_sun_end.Value = Format(CDate(hsh("mm_sun_e nd")), "mm")
End Sub
Protected Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect("supervi sor_menu.a spx")
End Sub
Protected Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect("supervi sor_menu.a spx")
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScri
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body bgColor="whitesmoke" MS_POSITIONING="GridLayout
<form id="Form1" method="post" runat="server">
<asp:button id="btnCancelTop" style="Z-INDEX: 108; LEFT: 24px; POSITION: absolute; TOP: 16px"
OnClick="btnCancel_Click" runat="server" Width="168px" Height="25px" Text="Cancel and Return to Menu"
CausesValidation="True"></
<asp:button id="btnSaveTop" style="Z-INDEX: 119; LEFT: 208px; POSITION: absolute; TOP: 16px"
OnClick="btnSave_Click" runat="server" Width="160px" Height="25px" Text="Save and Return to Menu"
CausesValidation="True"></
<asp:button id="btnCancelBottom" style="Z-INDEX: 106; LEFT: 24px; POSITION: absolute; TOP: 480px"
OnClick="btnCancel_Click" runat="server" Width="168px" Height="25px" Text="Cancel and Return to Menu"></asp:button>
<asp:button id="btnSaveBottom" style="Z-INDEX: 107; LEFT: 208px; POSITION: absolute; TOP: 480px"
OnClick="btnSave_Click" runat="server" Width="160px" Height="25px" Text="Save and Return to Menu"></asp:button>
<asp:label id="lblENV" style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 88px" runat="server"
Width="152px" Height="8px" Font-Bold="True" ForeColor="#0033FF">Enviro
<asp:dropdownlist
id="listENV"
style="Z-INDEX: 101; LEFT: 192px; POSITION: absolute; TOP: 88px"
runat="server"
OnSelectedIndexChanged="li
AutoPostBack="True"
Width="108px"
Height="40px"
Enabled="True"
EnableViewState="True"
Visible="True"></asp:dropd
<asp:requiredfieldvalidato
Width="16px" Height="8px" ErrorMessage="RequiredFiel
<asp:label id="lblDatabaseNum" style="Z-INDEX: 104; LEFT: 25px; POSITION: absolute; TOP: 120px"
runat="server" Width="152px" Height="10px" Font-Bold="True" ForeColor="#0033FF">Databa
<asp:textbox id="txtDatabaseNum" style="Z-INDEX: 102; LEFT: 192px; POSITION: absolute; TOP: 120px"
OnTextChanged="txtDatabase
<asp:requiredfieldvalidato
runat="server" Width="16px" Height="8px" ErrorMessage="RequiredFiel
<asp:label id="lblSoftwareTree" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 155px"
runat="server" Width="152px" Height="10px" Font-Bold="True" ForeColor="#0033FF">Sofwar
<asp:textbox id="txtSoftwareTree" style="Z-INDEX: 109; LEFT: 192px; POSITION: absolute; TOP: 152px"
runat="server" Width="105px" Height="22px" MaxLength="3" AutoPostBack="True"></asp:
<asp:requiredfieldvalidato
runat="server" Width="8px" Height="8px" ErrorMessage="RequiredFiel
<asp:label id="lblActive" style="Z-INDEX: 112; LEFT: 24px; POSITION: absolute; TOP: 192px"
runat="server" Width="152px" Height="8px" Font-Bold="True" ForeColor="Blue">Database is active:</asp:label>
<asp:checkbox id="chkActive" style="Z-INDEX: 110; LEFT: 192px; POSITION: absolute; TOP: 192px"
runat="server" Width="104px" Height="24px" AutoPostBack="True"></asp:
<asp:table id="tblPrimeTimeEntry" style="Z-INDEX: 111; LEFT: 24px; POSITION: absolute; TOP: 288px"
runat="server" Width="50%" BorderColor="Black" BorderStyle="Solid">
<asp:TableRow>
<asp:TableCell>
Monday thru Friday
</asp:TableCell>
<asp:TableCell>
<input name="hh_mon_fri_start" type="text" value="07" maxlength="2" id="hh_mon_fri_start"
runat="server" style="color:Black;backgro
:
<input name="mm_mon_fri_start" type="text" value="00" maxlength="2" id="mm_mon_fri_start"
runat="server" style="color:Black;backgro
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_mon_fri_end" type="text" value="19" maxlength="2" id="hh_mon_fri_end" runat="server"
style="color:Black;backgro
:
<input name="mm_mon_fri_end" type="text" value="00" maxlength="2" id="mm_mon_fri_end" runat="server"
style="color:Black;backgro
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
Saturday
</asp:TableCell>
<asp:TableCell>
<input name="hh_sat_start" type="text" value="00" maxlength="2" id="hh_sat_start" runat="server"
style="color:Black;backgro
:
<input name="mm_sat_start" type="text" value="00" maxlength="2" id="mm_sat_start" runat="server"
style="color:Black;backgro
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_sat_end" type="text" value="00" maxlength="2" id="hh_sat_end" runat="server"
style="color:Black;backgro
:
<input name="mm_sat_end" type="text" value="00" maxlength="2" id="mm_sat_end" runat="server"
style="color:Black;backgro
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
Sunday
</asp:TableCell>
<asp:TableCell>
<input name="hh_sun_start" type="text" value="00" maxlength="2" id="hh_sun_start" style="color:Black;backgro
:
<input name="mm_sun_start" type="text" value="00" maxlength="2" id="mm_sun_start" style="color:Black;backgro
</asp:TableCell>
<asp:TableCell Width="5%">
</asp:TableCell>
<asp:TableCell>
<input name="hh_sun_end" type="text" value="00" maxlength="2" id="hh_sun_end" style="color:Black;backgro
:
<input name="mm_sun_end" type="text" value="00" maxlength="2" id="mm_sun_end" style="color:Black;backgro
</asp:TableCell>
</asp:TableRow>
</asp:table>
<asp:validationsummary id="vsAddDB" style="Z-INDEX: 113; LEFT: 384px; POSITION: absolute; TOP: 64px" runat="server"
Width="256px" Height="264px"></asp:valid
runat="server" Width="152px" Height="8px" Font-Bold="True" ForeColor="Blue" Enabled="False">Permitted Nodes for Execution:</asp:label><asp
runat="server" Width="169px" Height="16px" AutoPostBack="True" Enabled="False"></asp:drop
</form>
</body>
</HTML>
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Protected hh_mon_fri_start As System.Web.UI.HtmlControls
Protected mm_mon_fri_start As System.Web.UI.HtmlControls
Protected hh_mon_fri_end As System.Web.UI.HtmlControls
Protected mm_mon_fri_end As System.Web.UI.HtmlControls
Protected hh_sat_start As System.Web.UI.HtmlControls
Protected mm_sat_start As System.Web.UI.HtmlControls
Protected hh_sat_end As System.Web.UI.HtmlControls
Protected mm_sat_end As System.Web.UI.HtmlControls
Protected hh_sun_start As System.Web.UI.HtmlControls
Protected mm_sun_start As System.Web.UI.HtmlControls
Protected hh_sun_end As System.Web.UI.HtmlControls
Protected mm_sun_end As System.Web.UI.HtmlControls
Protected WithEvents btnCancelTop As System.Web.UI.WebControls.
Protected WithEvents btnSaveTop As System.Web.UI.WebControls.
Protected WithEvents btnCancelBottom As System.Web.UI.WebControls.
Protected WithEvents btnSaveBottom As System.Web.UI.WebControls.
Protected WithEvents lblENV As System.Web.UI.WebControls.
Protected WithEvents listENV As System.Web.UI.WebControls.
Protected WithEvents reqENV As System.Web.UI.WebControls.
Protected WithEvents lblDatabaseNum As System.Web.UI.WebControls.
Protected WithEvents txtDatabaseNum As System.Web.UI.WebControls.
Protected WithEvents reqDatabaseNum As System.Web.UI.WebControls.
Protected WithEvents lblSoftwareTree As System.Web.UI.WebControls.
Protected WithEvents txtSoftwareTree As System.Web.UI.WebControls.
Protected WithEvents reqSoftwareTree As System.Web.UI.WebControls.
Protected WithEvents lblActive As System.Web.UI.WebControls.
Protected WithEvents chkActive As System.Web.UI.WebControls.
Protected WithEvents tblPrimeTimeEntry As System.Web.UI.WebControls.
Protected WithEvents vsAddDB As System.Web.UI.WebControls.
Protected WithEvents lblPermittedNodes As System.Web.UI.WebControls.
Protected WithEvents dlstPermittedNodes As System.Web.UI.WebControls.
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
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()
End Sub
#End Region
Private m_adb As AvailabilityDBaccess
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim i As Integer
Dim evl As System.Diagnostics.EventLo
Dim hshArray() As Hashtable
If Not IsPostBack Then
Response.Cache.SetExpires(
Response.Cache.SetCacheabi
Response.Cache.SetValidUnt
evl = New System.Diagnostics.EventLo
If Not evl.SourceExists("SBODispl
evl.CreateEventSource("SBO
End If
evl.Source = "SBODisplayStatus"
m_adb = New AvailabilityDBaccess(evl, False, Request.PhysicalApplicatio
Session("adb") = m_adb
hshArray = m_adb.getAllEnvironments()
listENV.Items.Clear()
listENV.Items.Add("")
listENV.Items(0).Value = 0
For i = 0 To hshArray.Length - 1
listENV.Items.Add(hshArray
listENV.Items(i).Value = CType(hshArray(i)("env_id"
Next
Else
'm_adb = Session("adb")
End If
End Sub
Protected Sub listENV_IndexChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listENV.SelectedIndexChang
ViewState("listENVSelected
If listENV.SelectedIndex < 1 Then
ViewState("env_name") = ""
Else
ViewState("env_name") = listENV.SelectedItem.Text
End If
End Sub
Protected Sub txtDatabaseNum_TextChanged
Dim env_name As String
Dim database_num As String
Dim hsh As Hashtable
listENV.SelectedIndex = ViewState("listENVSelected
env_name = ViewState("env_name")
database_num = Trim(txtDatabaseNum.Text)
hsh = m_adb.getDatabaseSetupByEn
chkActive.Checked = hsh("active") <> 0
hh_mon_fri_start.Value = Format(CDate(hsh("hh_mon_f
hh_mon_fri_end.Value = Format(CDate(hsh("hh_mon_f
hh_sat_start.Value = Format(CDate(hsh("hh_sat_s
hh_sat_end.Value = Format(CDate(hsh("hh_sat_e
hh_sun_start.Value = Format(CDate(hsh("hh_sun_s
hh_sun_end.Value = Format(CDate(hsh("hh_sun_e
mm_mon_fri_start.Value = Format(CDate(hsh("mm_mon_f
mm_mon_fri_end.Value = Format(CDate(hsh("mm_mon_f
mm_sat_start.Value = Format(CDate(hsh("mm_sat_s
mm_sat_end.Value = Format(CDate(hsh("mm_sat_e
mm_sun_start.Value = Format(CDate(hsh("mm_sun_s
mm_sun_end.Value = Format(CDate(hsh("mm_sun_e
End Sub
Protected Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect("supervi
End Sub
Protected Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect("supervi
End Sub
End Class
hi,
i used your aspx droplist only as i use c#, it posted back ok...
does the page post back at all when you change selected item? tip - put a break point in all your event handlers to see if one of the other event handlers are handling it first...
i used your aspx droplist only as i use c#, it posted back ok...
does the page post back at all when you change selected item? tip - put a break point in all your event handlers to see if one of the other event handlers are handling it first...
ASKER
You're gonna be very surpised (as I was) but the answer turned out to be that the way I was attempting to set the value property of a list item in the code-behind caused the event not to fire. It was very subtle; the compiler didn't catch it, and the runtime did not throw an error, so I assume this usage has a legitimate purpose of some sort. One of the offending lines is this:
listENV.Items(i).Value = CType(hshArray(i)("env_id" ), Int32)
It looks perfectly correct, but THIS is the correct form:
listENV.Items.Item(i).Valu e = CType(hshArray(i)("env_id" ), Int32)
With the first line in place, my SelectedIndexChanged event would not fire; with the second line in place, it did fire.
I used the following test code (simply change Items.Item(i) to Items(i) and you should duplicate the problem immediately):
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx. vb" Inherits="DB_Status.WebFor m2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScri pt" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="listENV" style="Z-INDEX: 101; LEFT: 216px; POSITION: absolute; TOP: 64px"
runat="server" Width="72px" Height="56px" AutoPostBack="True">
</asp:DropDownList>
</form>
</body>
</HTML>
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
End Sub
Protected WithEvents listENV As System.Web.UI.WebControls. DropDownLi st
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara tion As System.Object
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()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
listENV.Items.Clear()
listENV.Items.Add("1")
listENV.Items.Item(0).Valu e = 10
listENV.Items.Add("2")
listENV.Items.Item(1).Valu e = 11
listENV.Items.Add("3")
listENV.Items.Item(2).Valu e = 12
listENV.Items.Add("4")
listENV.Items.Item(3).Valu e = 13
End If
End Sub
Protected Sub listENV_SelectedIndexChang e(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listENV.SelectedIndexChang ed
Response.Write("Fired " & CStr(listENV.SelectedIndex ) & ", value is " & listENV.Items.Item(listENV .SelectedI ndex).Valu e)
End Sub
End Class
Does this mean I get the points for answering my own question? :)
BTW, thanks for the help, guys, being told it worked out of the box in a simple scenario gave me the confidence to apply my experience to the problem (I found it by commenting out lines one by one).
listENV.Items(i).Value = CType(hshArray(i)("env_id"
It looks perfectly correct, but THIS is the correct form:
listENV.Items.Item(i).Valu
With the first line in place, my SelectedIndexChanged event would not fire; with the second line in place, it did fire.
I used the following test code (simply change Items.Item(i) to Items(i) and you should duplicate the problem immediately):
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScri
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="listENV" style="Z-INDEX: 101; LEFT: 216px; POSITION: absolute; TOP: 64px"
runat="server" Width="72px" Height="56px" AutoPostBack="True">
</asp:DropDownList>
</form>
</body>
</HTML>
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Protected WithEvents listENV As System.Web.UI.WebControls.
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
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()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
listENV.Items.Clear()
listENV.Items.Add("1")
listENV.Items.Item(0).Valu
listENV.Items.Add("2")
listENV.Items.Item(1).Valu
listENV.Items.Add("3")
listENV.Items.Item(2).Valu
listENV.Items.Add("4")
listENV.Items.Item(3).Valu
End If
End Sub
Protected Sub listENV_SelectedIndexChang
Response.Write("Fired " & CStr(listENV.SelectedIndex
End Sub
End Class
Does this mean I get the points for answering my own question? :)
BTW, thanks for the help, guys, being told it worked out of the box in a simple scenario gave me the confidence to apply my experience to the problem (I found it by commenting out lines one by one).
i found a very similar issue with changing data in a datarow in c#
using DataRow.ItemArray[0] = "value" didnt work even though the comments said Get or Set!
using DataRow[0] = "value" did work
using DataRow.ItemArray[0] = "value" didnt work even though the comments said Get or Set!
using DataRow[0] = "value" did work
ASKER
Indeed, that does seem parallel. And, in fact, though I initially had a working event handler, after a few code changes even the value assignment I used above (....Items.Item(i).Value) caused the event to fail to fire. When I have time, I will no doubt post this to the MSDN newsgroups and see if the MS key players have anything to say on the subject. As ASP.NET does considerable code generation, it's quite possible this is a hole in that generation.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OnSelectedIndexChanged="li
as the event handler has the handles statement ..
But i am confused with the code within the selectedindexchanged event .. y do u need to save the values in viewstate? if its just to get the selected value .. u could use the code
listENV.SelectedValue ....