As I told earlier, I read these values out a asp.net-ListBox control. When I try to hide it, the engine won't send it to the browser, so Js cannot read these values, because the control doesn't even exist! I've got this:
<script type="text/javascript">
$(document).ready(function () {
// populate User Array
var arruser = new Array();
var listbox = document.getElementById('<%=lbxUser.ClientID%>');
for (var count = 0; count < listbox.options.length; count++) {
arruser[count] = listbox.options[count].text;
}
});
</script>
<asp:ListBox ID="lbxUser" runat="server" DataSourceID="User"
DataTextField="User" DataValueField="User" Visible="false"></asp:ListBox>
<asp:SqlDataSource ID="User" runat="server"
ConnectionString="<%$ ConnectionStrings:Japlas_Kaizen %>"
SelectCommand="SELECT lastName + ' ' + firstName + ', ' + FK_Department AS 'User' FROM [User] ORDER BY lastName, firstName, FK_Department">
</asp:SqlDataSource>
ronin47
Member
62 Points
73 Posts
Re: Javascript: Getting Content of ListBox
Mar 02, 2012 01:40 PM|LINK
Hello,
Sry I still have troubles concerning this thing.
As I told earlier, I read these values out a asp.net-ListBox control. When I try to hide it, the engine won't send it to the browser, so Js cannot read these values, because the control doesn't even exist! I've got this:
<script type="text/javascript"> $(document).ready(function () { // populate User Array var arruser = new Array(); var listbox = document.getElementById('<%=lbxUser.ClientID%>'); for (var count = 0; count < listbox.options.length; count++) { arruser[count] = listbox.options[count].text; } }); </script> <asp:ListBox ID="lbxUser" runat="server" DataSourceID="User" DataTextField="User" DataValueField="User" Visible="false"></asp:ListBox> <asp:SqlDataSource ID="User" runat="server" ConnectionString="<%$ ConnectionStrings:Japlas_Kaizen %>" SelectCommand="SELECT lastName + ' ' + firstName + ', ' + FK_Department AS 'User' FROM [User] ORDER BY lastName, firstName, FK_Department"> </asp:SqlDataSource>Any help would be appreciated :) Thx!