Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 18th, 2006, 01:38 PM
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2005
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing asp control id to javascript

I am trying to call a Javascript function that will receive the ID of two asp listbox controls. I then would like to set these id's to variables that I will declare in the javascript. The function call is in bold below. It is done in codebehind.

((HtmlInputButton)e.Item.FindControl("btnPutIn")). Attributes.Add("onclick","moveSelectedOptions(docu ment.getElementById('"+e.Item.FindControl("lbOut") .ClientID+"'),document.getElementById('"+e.Item.Fi ndControl("lbIn").ClientID+"'),false);JASONSNEWFUNCTION(document.getElementById('"+e.Ite m.FindControl("lbIn").ClientID+"'),document.getEle mentById('"+e.Item.FindControl("txtDisplayText").C lientID+"'),false);return false;");

Javascript function looks like this, it exists in a separate js file:

function JASONSNEWFUNCTION(lbin,txtdisplay) {

var mylist=document.getElementById("lbin");

var mydisplay=document.getElementById("txtdisplay");


Visual Studio keeps telling me that my declared variables have a null value. But lbin and txtdispay do bring back id's when i check their values in the immediate window. I am very confused.I know that the function is being called. ( a good thing I guess!) Is there something wrong with my getElementById statement?


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing values from asp to a javascript Abhilash Classic ASP Basics 11 June 15th, 2011 12:38 PM
Getting id of a control in javascript sudhir164 Javascript How-To 2 February 23rd, 2008 05:35 AM
Master pages &server control ID - asp.net 2.0 tech user C# 2005 1 August 3rd, 2006 04:31 AM
how to get ID of server-control in Javascript? hertendreef ASP.NET 2.0 Basics 0 June 15th, 2006 12:05 PM
Get the Id of Control in ASP rekha_jsr Classic ASP Professional 2 June 14th, 2006 07:37 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.