473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Changing items in aspx listbox from javascript

I am having trouble changing any properties of the web form listbox from
client side javascript.

As an example, all of the lines below seem to cause an error...

temp = document.getElementById("dropCategory1").length
window.alert("temp = " + temp)
document.getElementById("dropCategory1").Items.Cle ar()

Can the web form listbox be seen from client side javascript?

Thanks in advance.

Jim
Nov 22 '05 #1
2 3379
Yes, the problem is that the ID of the listbox changes once it is
rendered in the final output.

You can try something like this:

temp = document.getElementById("<%= dropCategory1.ClientID %>");

Which should give you the ID of the control once it has been rendered on
the page.

Thanks,
Sean

Jim M wrote:
I am having trouble changing any properties of the web form listbox from
client side javascript.

As an example, all of the lines below seem to cause an error...

temp = document.getElementById("dropCategory1").length
window.alert("temp = " + temp)
document.getElementById("dropCategory1").Items.Cle ar()

Can the web form listbox be seen from client side javascript?

Thanks in advance.

Jim

Nov 22 '05 #2
You can, do it all the time, what is the error it is throwing?
I assume that you declared temp somewhere above this with var temp;
If not, try var temp=....
Eventhough they may not alway throw an error, use your semicolons as good
measure at the end of each line.

"Jim M" <an********@discussions.microsoft.com> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
I am having trouble changing any properties of the web form listbox from
client side javascript.

As an example, all of the lines below seem to cause an error...

temp = document.getElementById("dropCategory1").length
window.alert("temp = " + temp)
document.getElementById("dropCategory1").Items.Cle ar()

Can the web form listbox be seen from client side javascript?

Thanks in advance.

Jim

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vengeance | last post by:
On the parent_form.aspx I have these controls <asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox> <INPUT class="loButton" onclick="java...
2
by: Jim M | last post by:
I am having trouble changing any properties of the web form listbox from client side javascript. As an example, all of the lines below seem to cause an error... temp =...
6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
3
by: Ryan Taylor | last post by:
Hello. I have an application where I need the user to be able to add items to a listbox. I've implemented this via javascript. The listbox is an <asp:ListBox>. However, when the user submits the...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
6
by: segue | last post by:
Hi; I need to change the order of a listbox array from a form app where I select order up or down. What's a good way to do that? Regards; Segue
3
by: Brian Simmons | last post by:
Hi All, I search on codeproject and google but didn't find what I was looking for. Anybody know of a good implementation where you have 2 listboxes and you want to move items between the 2. ...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.