473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

User Control Access from Javascript

Hi all,

I have a user control that uses control literal to build
a heading with a link, and a div containing links below.

As the link heading is hit, I want to change the style of
the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse
(Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a
client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error
I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4
7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc
mxzO0ltYWdlTGlua0xlZnRJbWFnZVVybDtJbWFnZUxpbmtMZWZ 0VmlzaWJ
sZTtVc2VyUGFnZXM7PjtsPGk8MD47QDxDb250ZW50O01haW50L lBhZ2U7R
GVsZXRlIFBhZ2U7PjtAPENvbnRlbnQuYXNweD9QYWdlSW5kZXg 9MDtNYWl
udFBhZ2UuYXNweD9QYWdlSW5kZXg9MDtEZWxldGVQYWdlLmFzc Hg/UGFnZ
UluZGV4PTA7PjsuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzt vPHQ+O0B
UQ1MuQ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aMmgwYUdGdVpHMXZ aSFZzWlh
NQkFBWUdDQUlBQUFBR0F3QUFBQVpRWVdkbElESFFCd0FBQ1FRQ UFBQUpCU
UFBQUJFRUFBQUFBUUFBQUFZR0FBQUFBQkVGQUFBQUFRQUFBQWt HQUFBQUN
3PT0+Oz47Pj47PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY
WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs
+O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V
mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo
/blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%">&nbsp;</TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx?PageIndex=0">Maint.Page</a></td><td
class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css"
rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD>
</TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a>&nbsp;Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style='
FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a>&nbsp;Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete
Nov 18 '05 #1
11 4951
Hi Pete,

You'll need to use the getElementById() javascript function. In your client
script block:

function Doexpandcollapse(whichElement)
{
getElementById(whichElement).style.display=
(getElementById(whichElement).style.display="none" )?" ":"none";
}

-- Alex Papadimoulis

"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build
a heading with a link, and a div containing links below.

As the link heading is hit, I want to change the style of
the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse
(Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a
client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error
I have also tried document.all.whichElement
[snip]

Nov 18 '05 #2
I just had the same problem. Check the generated HTML (View Source) and you
will see that the name of the user control is prepended to the ID. You will
have to find the control with the name UC:Element.

Lloyd Sheen

"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build
a heading with a link, and a div containing links below.

As the link heading is hit, I want to change the style of
the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse
(Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a
client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error
I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4
7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc
mxzO0ltYWdlTGlua0xlZnRJbWFnZVVybDtJbWFnZUxpbmtMZWZ 0VmlzaWJ
sZTtVc2VyUGFnZXM7PjtsPGk8MD47QDxDb250ZW50O01haW50L lBhZ2U7R
GVsZXRlIFBhZ2U7PjtAPENvbnRlbnQuYXNweD9QYWdlSW5kZXg 9MDtNYWl
udFBhZ2UuYXNweD9QYWdlSW5kZXg9MDtEZWxldGVQYWdlLmFzc Hg/UGFnZ
UluZGV4PTA7PjsuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzt vPHQ+O0B
UQ1MuQXBwbGljYXRpb25zLk5ldC50Y3NJbnRyYW5ldFBvcnRhb C5JbnRyY
W5ldFBhZ2UsIHRjc0ludHJhbmV0Q2xhc3NlcywgVmVyc2lvbj0 xLjAuMC4
wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51b Gw8YjxBQ
UVBQUFELy8vLy9BUUFBQUFBQUFBQU1BZ0FBQUVsMFkzTkpiblJ 5WVc1bGR
FTnNZWE56WlhNc0lGWmxjbk5wYjI0OU1TNHdMakF1TUN3Z1EzV nNkSFZ5W
lQxdVpYVjBjbUZzTENCUWRXS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q8c DxwPGw8V
mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo
/blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%">&nbsp;</TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx?PageIndex=0">Maint.Page</a></td><td
class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css"
rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD>
</TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a>&nbsp;Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style='
FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a>&nbsp;Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

Nov 18 '05 #3
Pete,

Another thing to note is that the ID on the server will often vary on the
client.

You may need to pass to your clientside javascript function the Client ID of
the Div: Personal.ClientID

-- Alex Papadimoulis
"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build
a heading with a link, and a div containing links below.

As the link heading is hit, I want to change the style of
the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse
(Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a
client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error
I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4
7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc
mxzO0ltYWdlTGlua0xlZnRJbWFnZVVybDtJbWFnZUxpbmtMZWZ 0VmlzaWJ
sZTtVc2VyUGFnZXM7PjtsPGk8MD47QDxDb250ZW50O01haW50L lBhZ2U7R
GVsZXRlIFBhZ2U7PjtAPENvbnRlbnQuYXNweD9QYWdlSW5kZXg 9MDtNYWl
udFBhZ2UuYXNweD9QYWdlSW5kZXg9MDtEZWxldGVQYWdlLmFzc Hg/UGFnZ
UluZGV4PTA7PjsuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzt vPHQ+O0B
UQ1MuQXBwbGljY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dGdVpHMXZ aSFZzWlh
NQkFBWUdDQUlBQUFBR0F3QUFBQVpRWVdkbElESFFCd0FBQ1FRQ UFBQUpCU
UFBQUJFRUFBQUFBUUFBQUFZR0FBQUFBQkVGQUFBQUFRQUFBQWt HQUFBQUN
3PT0+Oz47Pj47PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY
WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs
+O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V
mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo
/blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%">&nbsp;</TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx?PageIndex=0">Maint.Page</a></td><td
class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css"
rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD>
</TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a>&nbsp;Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style='
FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a>&nbsp;Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

Nov 18 '05 #4
Hi all,

Thanks for the replies. I'm still having the problem.

Looking at the rendered HTML the DIV has definately got
the ID of Personal and has not been prefixed with the
user control. With regard to using the client ID, I
thought this would only be for controls where the ID is
generated by ASP.NET (HTML included below).

I have also tried the getElementById in the client script
block. Here is the script as rendered at runtime.

As the function executes I get the message Personal is
undefined.

/*
<SCRIPT LANGUAGE=javascript>function ExpandCollapse
(whichElement){a=document.getElementById(whichElem ent);}
</SCRIPT>
*/

Heres the HTML:

/*
<TD id="Links1_tblCellContent"
colspan="2"><h5 STYLE='COLOR:blue'><a STYLE='CURSOR:
hand;' onclick='DoExpandCollapse(Personal)'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a>&nbsp;Personal</h5><DIV
style=' display: none; ID=Personal><LI style=' FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink1</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink2</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink3</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink4</LI></DIV><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse(Test)'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a>&nbsp;Test</h5><DIV style='
display: none; ID=Test><LI style=' FONT-WEIGHT: bold;
FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-STYLE-TYPE:
disc'><a style='CURSOR: hand; COLOR: blue; TEXT-
DECORATION: none;' href='http://www.trinitypartner.com'
alt='Trinity Partner Web Site'></a>My Other Link</LI><LI
style=' display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt;
FONT-FAMILY: Arial; LIST-STYLE-TYPE: disc'><a
style='CURSOR: hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner
Web Site'></a>My Other Link3</LI></TD> */

Regards, Pete.

-----Original Message-----
I just had the same problem. Check the generated HTML (View Source) and youwill see that the name of the user control is prepended to the ID. You willhave to find the control with the name UC:Element.

Lloyd Sheen

"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build a heading with a link, and a div containing links below.
As the link heading is hit, I want to change the style of the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse (Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4 7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc mxzO0ltYWdlTGlua0xlZnRJbWFnZVVybDtJbWFnZUxpbmtMZWZ 0VmlzaWJ sZTtVc2VyUGFnZXM7PjtsPGk8MD47QDxDb250ZW50O01haW50L lBhZ2U7R GVsZXRlIFBhZ2U7PjtAPENvbnRlbnQuYXNweD9QYWdlSW5kZXg 9MDtNYWl udFBhZ2UuYXNweD9QYWdlSW5kZXg9MDtEZ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UFad1lXZGxhV1FPYzJWeGRXVnVZMlZ1Z FcxaVpYS VBiR1ZtZEdoaGJtUnRiMlIxYkdWekVISnBaMmgwYUdGdVpHMXZ aSFZzWlh NQkFBWUdDQUlBQUFBR0F3QUFBQVpRWVdkbElESFFCd0FBQ1FRQ UFBQUpCU UFBQUJFRUFBQUFBUUFBQUFZR0FBQUFBQkVGQUFBQUFRQUFBQWt HQUFBQUN 3PT0+Oz47Pj47PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs +O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo /blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%"> </TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx? PageIndex=0">Maint.Page</a></td><td class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css" rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD> </TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a> Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a> Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

.

Nov 18 '05 #5
Please see reply to Lloyd.

Pete.
-----Original Message-----
Pete,

Another thing to note is that the ID on the server will often vary on theclient.

You may need to pass to your clientside javascript function the Client ID ofthe Div: Personal.ClientID

-- Alex Papadimoulis
"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build a heading with a link, and a div containing links below.
As the link heading is hit, I want to change the style of the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse (Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+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YjxBQUVBQUFELy8vLy9BUUF BQUFBQUF BQU1BZ0FBQUVsMFkzTkpiblJ5WVc1bGRFTnNZWE56WlhNc0lGW mxjbk5wY jI0OU1TNHdMakF1TUN3Z1EzVnNkSFZ5WlQxdVpYVjBjbUZzTEN CUWRXSnN hV05MWlhsVWIydGxiajF1ZFd4c0JRRUFBQUF6VkVOVExrRndjR 3hwWTJGM GFXOXVjeTVPWlhRdWRHTnpTVzUwY21GdVpYUlFiM0owWVd3dVN XNTBjbUZ 1WlhSUVlXZGxCQUFBQUFad1lXZGxhV1FPYzJWeGRXVnVZMlZ1Z FcxaVpYS VBiR1ZtZEdoaGJtUnRiMlIxYkdWekVISnBaMmgwYUdGdVpHMXZ aSFZzWlh NQkFBWUdDQUlBQUFBR0F3QUFBQVpRWVdkbElESFFCd0FBQ1FRQ UFBQUpCU UFBQUJFRUFBQUFBUUFBQUFZR0FBQUFBQkVGQUFBQUFRQUFBQWt HQUFBQUN 3PT0+Oz47Pj47PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs +O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo /blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%"> </TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx? PageIndex=0">Maint.Page</a></td><td class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css" rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD> </TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a> Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a> Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

.

Nov 18 '05 #6
OK a little bit more info:

I have worked out that the undefined error message goes
away if I place the name in quotes when callinf the
script.

e.g. before ExpandCollapse(Personal) now ExpandCollapse
("Personal"), however, I still cant access the DIV
elements, so I changed the expand collapse script to get
all DIV tags and display the ID's like so:

function DoExpandCollapse()
{
alert('ExpandCollapse');
var coll = document.all.tags("DIV");
for (i=0; i<coll.length; i++)
{
alert(coll[i].id);
}
}

The ID's are showing as empty string but I can see the
TWO DIVs in the source one with an ID of Test and another
with an ID of Personal. - Whats happening to the ID's?

Pete.
-----Original Message-----
I just had the same problem. Check the generated HTML (View Source) and youwill see that the name of the user control is prepended to the ID. You willhave to find the control with the name UC:Element.

Lloyd Sheen

"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build a heading with a link, and a div containing links below.
As the link heading is hit, I want to change the style of the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse (Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4 7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc mxzO0ltYWdlTGlua0xlZnRJbWFnZVVybDtJbWFnZUxpbmtMZWZ 0VmlzaWJ sZTtVc2VyUGFnZXM7PjtsPGk8MD47QDxDb250ZW50O01haW50L lBhZ2U7R GVsZXRlIFBhZ2U7PjtAPENvbnRlbnQuYXNweD9QYWdlSW5kZXg 9MDtNYWl udFBhZ2UuYXNweD9QYWdlSW5kZXg9MDtEZWxldGVQYWdlLmFzc Hg/UGFnZ UluZGV4PTA7PjsuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzt vPHQ+O0B UQ1MuQXBwbGljYXRpb25zLk5ldC50Y3NJbnRyYW5ldFBvcnRhb C5JbnRyY W5ldFBhZ2UsIHRjc0ludHJhbmV0Q2xhc3NlcywgVmVyc2lvbj0 xLjAuMC4 wLCBDdWx0dXJlPW5ldXRyYWwsIFB1Y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PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs +O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo /blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%"> </TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx? PageIndex=0">Maint.Page</a></td><td class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css" rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD> </TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a> Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a> Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

.

Nov 18 '05 #7
GOT IT.....

I didn't think it mattered (maybe someone can confirm)
but the HTML I was rendering via the literal control for
the DIV was as follows:

/*<DIV style=' display: none; id="Personal">*/

Event changing the function to loop through elements I
could see the DIV but it had no ID. I changed the HTML

/*<DIV id="Personal"; style=' display: none;>*/

and it worked a treat?????????

I thought the order of HTML tags was irrelevant?

Pete.
-----Original Message-----
I just had the same problem. Check the generated HTML (View Source) and youwill see that the name of the user control is prepended to the ID. You willhave to find the control with the name UC:Element.

Lloyd Sheen

"trinitypete" <su*****@trinity.com> wrote in message
news:04****************************@phx.gbl...
Hi all,

I have a user control that uses control literal to build a heading with a link, and a div containing links below.
As the link heading is hit, I want to change the style of the div, making it visible or not. Yep you guessed it,
expanding tree type functionality.

The header has an onclick event onclick='Doexpandcollapse (Personal)'

The div is set as follows "<DIV> ID=Personal".

From the page load event in the user control I register a client script block.

function Doexpandcollapse(whichElement)
{
whichElement.style.display=
(whichelement.style.display="none")?" ":"none";
}

I get an error Personal is undefined.
I have also tried document.all.Personal get the same error I have also tried document.all.whichElement

none of them seem to be able to locate the DIV.

/*
<HEAD>
<title>DefaultPage</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="IntranetStyleSheet.css"
type="text/css" rel="stylesheet">
</HEAD>
<body bottomMargin="0" topMargin="10">
<form name="Form1" method="post"
action="Default.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtODk2MzgzMTIzO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDE+Oz4 7bDx0PHA8cDxsPFBhZ2VJbmRleDtPdGhlckxpbmtzO090aGVyT Glua3NVc mxzO0ltY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bk5wY jI0OU1TNHdMakF1TUN3Z1EzVnNkSFZ5WlQxdVpYVjBjbUZzTEN CUWRXSnN hV05MWlhsVWIydGxiajF1ZFd4c0JRRUFBQUF6VkVOVExrRndjR 3hwWTJGM GFXOXVjeTVPWlhRdWRHTnpTVzUwY21GdVpYUlFiM0owWVd3dVN XNTBjbUZ 1WlhSUVlXZGxCQUFBQUFad1lXZGxhV1FPYzJWeGRXVnVZMlZ1Z FcxaVpYS VBiR1ZtZEdoaGJtUnRiMlIxYkdWekVISnBaMmgwYUdGdVpHMXZ aSFZzWlh NQkFBWUdDQUlBQUFBR0F3QUFBQVpRWVdkbElESFFCd0FBQ1FRQ UFBQUpCU UFBQUJFRUFBQUFBUUFBQUFZR0FBQUFBQkVGQUFBQUFRQUFBQWt HQUFBQUN 3PT0+Oz47Pj47PjtsPGk8MT47aTwzPjtpPDU+Oz47bDx0PHA8c DxsPEltY WdlVXJsOz47bDwuLi9pbWFnZXMvdHJpbml0eV9sb2dvLmpwZzs +Pjs+Ozs +O3Q8cDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+O3Q8c DxwPGw8V mlzaWJsZTs+O2w8bzxmPjs+Pjs+Ozs+Oz4+Oz4+Oz4+Oz4VjdJ yQDGO4uo /blpMHMc/AvRcPg==" />

<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD noWrap><a
id="PageHeaderControl_ImageLinkLeft"><img
src="images/trinity_logo.jpg" border="0" /></a></TD>
<TD noWrap align="center"></TD>
<TD noWrap align="right"></TD>
</TR>
<tr>
<td height="5"></td>
</tr>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<TR>
<TD id="PageHeaderControl_tblcellPages"
align="left" width="1%"><table cellspacing="0"
cellpadding="5" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="ActivePage" nowrap="nowrap"
align="Center"><a class="PageLink" href="default.aspx?
PageIndex=0">Home</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="PageLink"
href="default.aspx?PageIndex=1">Page 1</a></td>
</tr>
</table></TD>

<TD class="InactivePage"
width="98%"> </TD>
<TD id="PageHeaderControl_tblcellMaint"
align="right"><table cellspacing="0" cellpadding="5"
align="Right" border="0" style="width:100%;border-
collapse:collapse;">
<tr>
<td class="InactivePage" nowrap="nowrap"
align="Center"><a class="MaintLink" href="Content.aspx?
PageIndex=0">Content</a></td><td class="InactivePage"
nowrap="nowrap" align="Center"><a class="MaintLink"
href="MaintPage.aspx? PageIndex=0">Maint.Page</a></td><td class="InactivePage" nowrap="nowrap" align="Center"><a
class="MaintLink" href="DeletePage.aspx?
PageIndex=0">Delete Page</a></td>
</tr>
</table></TD>

</TR>
<TR>
<TD class="PagerBackground" colSpan="2"
height="4"></TD>
<TD class="PagerBackground"
height="4"></TD>
</TR>
</TABLE>
</P>
<P>

<LINK href="../../IntranetStyleSheet.css" type="text/css" rel="stylesheet">
<TABLE class="Dialogue" id="Table1" cellSpacing="0"
cellPadding="10" width="100%" border="0">
<TR>
<TD class="PagerBackground" style="FONT-
WEIGHT: bold" align="center" height="20">Favourite
Links</TD>
<TD class="PagerBackground" align="right"
width="2%" height="20"><input type="submit"
name="Links1:btnClose" value="X" id="Links1_btnClose"
class="CloseButton" style="height:0px;width:20px;" /></TD> </TR>
<TR>
<TD id=" " colspan="2"><h5
STYLE='COLOR:blue'><a STYLE='CURSOR: hand;'
onclick='DoExpandCollapse()'><IMG src='images/plus.jpg'
alt='Expand/Collapse Node' border='0'
height='10'></a> Personal</h5><DIV title = 'Yeh
right!' style=' display: none; ID='Personal'><LI style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial;
LIST-STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR:
blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink1</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink2</LI><LI style=' display: none; FONT-
WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Arial; LIST-
STYLE-TYPE: disc'><a style='CURSOR: hand; COLOR: blue;
TEXT-DECORATION: none;' href='http://www.microsoft.com'
alt='Microsofts Web Site'></a>MyLink3</LI><LI style='
display: none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-
FAMILY: Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR:
hand; COLOR: blue; TEXT-DECORATION: none;'
href='http://www.microsoft.com' alt='Microsofts Web
Site'></a>MyLink4</LI></DIV><h5 STYLE='COLOR:blue'><a
STYLE='CURSOR: hand;' onclick='DoExpandCollapse()'><IMG
src='images/plus.jpg' alt='Expand/Collapse Node'
border='0' height='10'></a> Test</h5><DIV title
= 'Yeh right!' style=' display: none; ID='Test'><LI
style=' FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link1</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link2</LI><LI style=' display:
none; FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY:
Arial; LIST-STYLE-TYPE: disc'><a style='CURSOR: hand;
COLOR: blue; TEXT-DECORATION: none;'
href='http://www.trinitypartner.com' alt='Trinity Partner Web Site'></a>My Other Link3</LI></TD>

</TR>
<TR>
<TD class="Pagerbackground" align="right"
height="20"></TD>
<TD class="Pagerbackground" noWrap
align="right" width="2%" height="20"><a
id="Links1_HyperLink1">Maintain Links</a></TD>
</TR>
</TABLE>
<script language="javascript">
<!--
function DoExpandCollapse()
{
alert(document.all.Personal);
/* alert(whichElement.id);
alert(whichElement.style.display);
whichElement.style.display =
(whichElement.style.display)?"":"none";*/
}
//-->
</script>
<INPUT id="mybutton" type="button" value="Button">
</P>
</form>
</body>
*/
Any help would be appreciated.....Pete

.

Nov 18 '05 #8
Hi Peter,

I am glad to know that the problem is resolved.

For the issue regarding the order of HTML tags, I cannot reproduce the
problem on my side. Please try the following simple code snippet on your
side.

--------------------------------------
<html>
<head>
<title>My Example</title>
<script language="Javascript">
var origDivHTML;

function init()
{
origDivHTML = myDiv.innerHTML;
}

function setValues()
{
var oldinnerHTML = "your original innerHTML: " + yourDiv.innerHTML ;
alert(oldinnerHTML);
yourDiv.innerHTML = origDivHTML;

var curinnerHTML = "your current innerHTML: " + yourDiv.innerHTML ;
alert(curinnerHTML);
}
</script>
</head>

<body onload="init()">

<div style="" id="myDiv">
<select name="firstSelect" size="1" >
<option>11111</option>
<option>22222</option>
<option>33333</option>
</select>
</div>

<div style="" id="yourDiv">
<select name="secondSelect" size="1" >
<option>aaaa</option>
<option>bbbb</option>
<option>cccc</option>
</select>
</div>
<button onclick = "setValues();">click me to set the values</button>
</body>
</html>
--------------------------------------

Would you pleaes try to reproduce the problem on your side with the above
testing sample? I certainly appreciate your time.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #9
Jacob,

Thanks for your reply and code snippet. I implemented the
code and it seemed fine, unsure what was happening in my
example other that the HTML was rendered from a user
control. I could zip up a quick example and send it to
you if you like? Please let me know.

Regards, Pete.
-----Original Message-----
Hi Peter,

I am glad to know that the problem is resolved.

For the issue regarding the order of HTML tags, I cannot reproduce the problem on my side. Please try the following simple code snippet on your side.

--------------------------------------
<html>
<head>
<title>My Example</title>
<script language="Javascript">
var origDivHTML;

function init()
{
origDivHTML = myDiv.innerHTML;
}

function setValues()
{
var oldinnerHTML = "your original innerHTML: " + yourDiv.innerHTML ; alert(oldinnerHTML);
yourDiv.innerHTML = origDivHTML;

var curinnerHTML = "your current innerHTML: " + yourDiv.innerHTML ; alert(curinnerHTML);
}
</script>
</head>

<body onload="init()">

<div style="" id="myDiv">
<select name="firstSelect" size="1" >
<option>11111</option>
<option>22222</option>
<option>33333</option>
</select>
</div>

<div style="" id="yourDiv">
<select name="secondSelect" size="1" >
<option>aaaa</option>
<option>bbbb</option>
<option>cccc</option>
</select>
</div>
<button onclick = "setValues();">click me to set the values</button></body>
</html>
--------------------------------------

Would you pleaes try to reproduce the problem on your side with the above testing sample? I certainly appreciate your time.

If I have misunderstood your concern, please feel free to let me know.
Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 18 '05 #10
Jacob,

OK I have tried to reproduce this again but the code has
moved on somewhat and now I am finding it impossible to
reproduce - isn't that usually the case. However, I do
have a theory.

The page is essentially made up of tables containing
various user controls. Each user control has tables
contained within it. Looking back at the original HTML
that was rendered in the first Mail, it looks as if
tables within the different user controls are getting
rendered with the same ID - Table 1 - I guess this has
got to cause problems, I know it still doesn't explain
the error I was originally getting.

Guess I will have to put this down as one of those things
as I am really struggling to reproduce.

Thanks for your help anyway....Pete

-----Original Message-----
Hi Peter,

I am glad to know that the problem is resolved.

For the issue regarding the order of HTML tags, I cannot reproduce the problem on my side. Please try the following simple code snippet on your side.

--------------------------------------
<html>
<head>
<title>My Example</title>
<script language="Javascript">
var origDivHTML;

function init()
{
origDivHTML = myDiv.innerHTML;
}

function setValues()
{
var oldinnerHTML = "your original innerHTML: " + yourDiv.innerHTML ; alert(oldinnerHTML);
yourDiv.innerHTML = origDivHTML;

var curinnerHTML = "your current innerHTML: " + yourDiv.innerHTML ; alert(curinnerHTML);
}
</script>
</head>

<body onload="init()">

<div style="" id="myDiv">
<select name="firstSelect" size="1" >
<option>11111</option>
<option>22222</option>
<option>33333</option>
</select>
</div>

<div style="" id="yourDiv">
<select name="secondSelect" size="1" >
<option>aaaa</option>
<option>bbbb</option>
<option>cccc</option>
</select>
</div>
<button onclick = "setValues();">click me to set the values</button></body>
</html>
--------------------------------------

Would you pleaes try to reproduce the problem on your side with the above testing sample? I certainly appreciate your time.

If I have misunderstood your concern, please feel free to let me know.
Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 18 '05 #11
Hi Peter,

Thank you for your update.

If you can zip up a quick example for reproducing the problem, please send
it to my email box - ya******@hotmail.com and notify me in this thread.
Personally, I prefer that you can show your reproducing sample and the
detailed reproducing steps in the newsgroup. It will be helpful to
everybody here.

If you cannot compose a simple reproducing example for this issue, please
try to change the value of the style and test this issue again. (Maybe this
issue is caused by the "display: none".)

On the other hand, as you have mentioned before, I agree with you that "I
didn't think it mattered" :-)

If you have any more concerns for this issue, please feel free to let me
know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
1
by: george d lake | last post by:
Hi, I have a user control that has a series of web controls in it. I need to access the web controls from the parent page via javascript. No, I have done this in the past but know I am having...
1
by: RSB | last post by:
Hi all, Sorry for asking to many questions.. one more problem. i have a Form and in that form i am adding a user control "myUserControl" which has two text boxes. textbox1 and textbox2. ...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
2
by: bill | last post by:
I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl
1
by: Barbara Alderton | last post by:
I have the following scenario: I have a user control that contains a registered menu control. The menu and other information on the user control is specific to the user accessing the site. ...
4
by: barry | last post by:
I have a <asp:panel defined on a asp.net 1.1 version. I have some javascript that is executed on an action in the panel. This works fine. but When I put the panel to an ascx file and then...
1
by: Shraddha | last post by:
Hi, I am adding some ASP.Net user controls (.ascx file) dynamically on the button click. The user control will get added as many times userhits the button. Now on the click of the submit button, I...
4
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.