DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 1 Aug 2007 10:02:00 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    AlBruAn .(donotspam)
          2    Laurent Bugnion, MVP
          3    Mark Rae [MVP]
          4    AlBruAn .(donotspam)
                 5    Laurent Bugnion, MVP


Javascript and DropDownLists question   
I have three dropdownlists in an AJAX UpdatePanel and I need to return the 
selected index for two of them; the problem is that I'm only able to return 
the selected index for the first dropdownlist of the three and it is the one 
that I don't need.  The dropdownlists are named, in order, ddlEntityType, 
ddlEntityGroups and ddlProcesses.  The Javascript for attempting to read the 
selected index is as follows:

    var entityTypeIndex = 
document.getElementById('ct100$ContentPlaceHolder1$ddlEntityType').selectedIndex;        // this one works
    var entityGroupIndex = 
document.getElementById('ct100$ContentPlaceHolder1$ddlEntityGroups').selectedIndex;     // this doesn't work
    var processesIndex = 
document.getElementById('ct100$ContentPlaceHolder1$ddlProcesses').selectedIndex;        // this doesn't work

Trying all three in the Immediate Window, the first one still works; the 
message I get back for the other two is:  Object required

Why won't it find the dropdownlists for the two that I need to return the 
SelectedIndex from?
Date:Wed, 1 Aug 2007 10:02:00 -0700   Author:  

Re: Javascript and DropDownLists question   
Hi,

AlBruAn wrote:

> I have three dropdownlists in an AJAX UpdatePanel and I need to return the 
> selected index for two of them; the problem is that I'm only able to return 
> the selected index for the first dropdownlist of the three and it is the one 
> that I don't need.  The dropdownlists are named, in order, ddlEntityType, 
> ddlEntityGroups and ddlProcesses.  The Javascript for attempting to read the 
> selected index is as follows:
> 
>     var entityTypeIndex = 
> document.getElementById('ct100$ContentPlaceHolder1$ddlEntityType').selectedIndex;        // this one works
>     var entityGroupIndex = 
> document.getElementById('ct100$ContentPlaceHolder1$ddlEntityGroups').selectedIndex;     // this doesn't work
>     var processesIndex = 
> document.getElementById('ct100$ContentPlaceHolder1$ddlProcesses').selectedIndex;        // this doesn't work
> 
> Trying all three in the Immediate Window, the first one still works; the 
> message I get back for the other two is:  Object required
> 
> Why won't it find the dropdownlists for the two that I need to return the 
> SelectedIndex from?


The unique name for the client, aka ClientId is generated by the server. 
You must make sure that 'ct100$ContentPlaceHolder1$ddlEntityGroups' and 
the other are really named this way. To make this sure, view the HTML 
source on the web client. In your server-side code, use the control's 
ClientId to generate the JavaScript code to get it.

HTH,
Laurent
-- 
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Date:Wed, 01 Aug 2007 19:31:41 +0200   Author:  

Re: Javascript and DropDownLists question   
"Laurent Bugnion, MVP"  wrote in message 
news:%238w5UHG1HHA.4880@TK2MSFTNGP03.phx.gbl...


>>     var entityTypeIndex = 
>> document.getElementById('ct100$ContentPlaceHolder1$ddlEntityType').selectedIndex; 
>> // this one works
>>     var entityGroupIndex = 
>> document.getElementById('ct100$ContentPlaceHolder1$ddlEntityGroups').selectedIndex; 
>> // this doesn't work
>>     var processesIndex = 
>> document.getElementById('ct100$ContentPlaceHolder1$ddlProcesses').selectedIndex; 
>> // this doesn't work


var entityTypeIndex = 
document.getElementById('<%=ddlEntityType.ClientID%>').selectedIndex;
var entityGroupIndex = 
document.getElementById('<%=ddlEntityGroups.ClientID%>').selectedIndex;
var processesIndex = 
document.getElementById('<%=ddlProcesses.ClientID%>').selectedIndex;


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Wed, 1 Aug 2007 18:43:26 +0100   Author:  

Re: Javascript and DropDownLists question   
Thanks for the tip.  I'd inadvertently typed the number "1" rather than the 
letter "l"; I thought I'd copied and pasted it, but apparently not.

"Laurent Bugnion, MVP" wrote:


> Hi,
> 
> AlBruAn wrote:
> > I have three dropdownlists in an AJAX UpdatePanel and I need to return the 
> > selected index for two of them; the problem is that I'm only able to return 
> > the selected index for the first dropdownlist of the three and it is the one 
> > that I don't need.  The dropdownlists are named, in order, ddlEntityType, 
> > ddlEntityGroups and ddlProcesses.  The Javascript for attempting to read the 
> > selected index is as follows:
> > 
> >     var entityTypeIndex = 
> > document.getElementById('ct100$ContentPlaceHolder1$ddlEntityType').selectedIndex;        // this one works
> >     var entityGroupIndex = 
> > document.getElementById('ct100$ContentPlaceHolder1$ddlEntityGroups').selectedIndex;     // this doesn't work
> >     var processesIndex = 
> > document.getElementById('ct100$ContentPlaceHolder1$ddlProcesses').selectedIndex;        // this doesn't work
> > 
> > Trying all three in the Immediate Window, the first one still works; the 
> > message I get back for the other two is:  Object required
> > 
> > Why won't it find the dropdownlists for the two that I need to return the 
> > SelectedIndex from?
> 
> The unique name for the client, aka ClientId is generated by the server. 
> You must make sure that 'ct100$ContentPlaceHolder1$ddlEntityGroups' and 
> the other are really named this way. To make this sure, view the HTML 
> source on the web client. In your server-side code, use the control's 
> ClientId to generate the JavaScript code to get it.
> 
> HTH,
> Laurent
> -- 
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog: http://www.galasoft.ch
> PhotoAlbum: http://www.galasoft.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch
> 
Date:Wed, 1 Aug 2007 11:18:02 -0700   Author:  

Re: Javascript and DropDownLists question   
Hi,

AlBruAn wrote:

> Thanks for the tip.  I'd inadvertently typed the number "1" rather than the 
> letter "l"; I thought I'd copied and pasted it, but apparently not.


That's why you shouldn't. You should use ClientID instead. This way, if 
the containing control's name changes, you don't need to change your code.

HTH,
Laurent
-- 
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Date:Thu, 02 Aug 2007 00:01:20 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us