hide drowndownList

J

JFB

Hi all,
This is crazy...
The name of my dropdownlist on the ascx page is:
nameOfMyControl_DropDownListName
Like:
contactWebUserControl_DropDownList2
Now I put my ascx in sharepoint and the name is :
<select
name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"

I have a fuction in java to catch this name as:
var drop2 = document.getElementById("contactWebUserControl_DropDownList2");

How can I do it now??
Tks

JFB
 
C

Cowboy \(Gregory A. Beamer\)

you have to link to JavaScript through code behind. This will catch the name
no matter what it is at run time.
 
E

Eliyahu Goldin

This javascript function will help you. Call it as

var drop2 = findControl("select", "contactWebUserControl_DropDownList2");

function findControl(tagName, controlId)
{
var aControls = document.getElementsByTagName(tagName);
if (aControls==null)
return null;
for (var i=0; i< aControls.length; i++)
{
var j = aControls.id.lastIndexOf(controlId);
if ((j > -1) && (j == (aControls.id.length - controlId.length)))
return aControls;
}
return null;
}
 
J

JFB

Tks for you reply Eliyahu,
Looks like it works but I got an error "style" is null or not an object.
What is this mean? Any ideas?
Rgds

JFB


Eliyahu Goldin said:
This javascript function will help you. Call it as

var drop2 = findControl("select", "contactWebUserControl_DropDownList2");

function findControl(tagName, controlId)
{
var aControls = document.getElementsByTagName(tagName);
if (aControls==null)
return null;
for (var i=0; i< aControls.length; i++)
{
var j = aControls.id.lastIndexOf(controlId);
if ((j > -1) && (j == (aControls.id.length - controlId.length)))
return aControls;
}
return null;
}


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


JFB said:
Hi all,
This is crazy...
The name of my dropdownlist on the ascx page is:
nameOfMyControl_DropDownListName
Like:
contactWebUserControl_DropDownList2
Now I put my ascx in sharepoint and the name is :
<select
name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"

I have a fuction in java to catch this name as:
var drop2 =
document.getElementById("contactWebUserControl_DropDownList2");

How can I do it now??
Tks

JFB
 
J

JFB

Never Mine Eliyahu... I got it...
I use only _DropDownList2 as name.
Tks
JFB


Eliyahu Goldin said:
This javascript function will help you. Call it as

var drop2 = findControl("select", "contactWebUserControl_DropDownList2");

function findControl(tagName, controlId)
{
var aControls = document.getElementsByTagName(tagName);
if (aControls==null)
return null;
for (var i=0; i< aControls.length; i++)
{
var j = aControls.id.lastIndexOf(controlId);
if ((j > -1) && (j == (aControls.id.length - controlId.length)))
return aControls;
}
return null;
}


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


JFB said:
Hi all,
This is crazy...
The name of my dropdownlist on the ascx page is:
nameOfMyControl_DropDownListName
Like:
contactWebUserControl_DropDownList2
Now I put my ascx in sharepoint and the name is :
<select
name="Left:g_708f9018_c320_46a1_bb9c_ebb3b67b8184:_ctl0:DropDownList2"
id="Left_g_708f9018_c320_46a1_bb9c_ebb3b67b8184__ctl0_DropDownList2"

I have a fuction in java to catch this name as:
var drop2 =
document.getElementById("contactWebUserControl_DropDownList2");

How can I do it now??
Tks

JFB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top