473,659 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getEle mentById("dropC ategory1").leng th
window.alert("t emp = " + temp)
document.getEle mentById("dropC ategory1").Item s.Clear()

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

Thanks in advance.

Jim
Nov 22 '05 #1
2 3416
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.getEle mentById("<%= dropCategory1.C lientID %>");

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.getEle mentById("dropC ategory1").leng th
window.alert("t emp = " + temp)
document.getEle mentById("dropC ategory1").Item s.Clear()

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********@dis cussions.micros oft.com> wrote in message
news:O8******** ******@TK2MSFTN GP09.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.getEle mentById("dropC ategory1").leng th
window.alert("t emp = " + temp)
document.getEle mentById("dropC ategory1").Item s.Clear()

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
2908
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 script:getOptionPicker('?mid=TS5 &callingcontrol=Operators');" type="button" value="+"> <asp:button id="save" runat="server" CssClass="loButton" Text="Save"> </asp:button> I also use a global.js file which adds the following functions
2
540
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 = document.getElementById("dropCategory1").length window.alert("temp = " + temp) document.getElementById("dropCategory1").Items.Clear() Can the web form listbox be seen from client side javascript?
6
6501
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 page does not know the items were added client-side.) TIA, Val
4
3705
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 find what I need so I can populate a DB. lstTest is dim'd as a ListBox, and I thought I could just do:
3
2721
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 form those items do not get posted. My listbox.Items.Count always returns 0. I want the user to be able to add items without having to resort to a postback, hence the javascript. But I need to be able to access those items in the code behind...
10
3285
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
7202
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
9982
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. I.e. << < >
1
3663
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" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.