hide drowndownList

  • Thread starter Thread starter JFB
  • Start date Start date
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
 
you have to link to JavaScript through code behind. This will catch the name
no matter what it is at run time.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
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;
}
 
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
 
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
 
Back
Top