getElementById doesn't seem to work

L

Lit

use this

var toResumeText = document.getElementById('<%=objResumeText.ClientID%>');



DO NOT USE THIS

_ctl0_ResumeDisplay_objResumeText.ClientID

_ctl0_ResumeDisplay_objResumeText is the ClientID



Lit



tshad said:
tshad said:
The asp.net line is:

<asp:Label ID="objResumeText" runat="server"/>

in the View Source it is:

<span id="_ctl0_ResumeDisplay_objResumeText"></span>

Could the error be because the objResumeText is in a User control
(ResumeDisplay)?

I assume that the problem is the User Controls, because I created a Label
on my main page with id of "theLabel" and this worked fine:

var toResumeText = document.getElementById('<%=theLabel.ClientID%>');

Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does. But even if it didn't, the commenting out
should prevent the error. This is the first time I have not been able
comment a line out.

Thanks,

Tom


Thanks,

Tom
if the ServerSide ID of your Label is MyLabel123 then use
<%=MyLabel123.ClientID%> -- verify syntax

Make sure Label is runat="server"

Lit




as i said, you need to use the childNodes, and a span does not have a
type or name property.

var nodes = document.forms[0].childNodes;
for (var i=0; i < nodes.length; ++i)
{
alert("tag: " + node.tagName + " id: " + nodes.id);
}

or lookup the span by id.

var theBox = document.getElementById('<%=theBox.ClientId%>');

I tried that but it gives me an error:

*******************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: // var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
*******************************************************

Here is the code:

var fromResumeText =
window.opener.document.getElementById('ctl0__ctl1_ResumeText');
var fromCoverLetter =
window.opener.document.getElementById('ctl0__ctl1_CoverLetter');
// var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');

I am looking for 2 objects on my opener page and 2 from my current
page. I can find all the objects except the
'ctl0_ResumeDisplay_objResumeText' which is the only object that is an
asp:Label.

This code worked fine except that it didn't find Label objects - it
found the other 3.

This error happened when I added the <%=...%> format.

The interesting thing is that I get the error even when I comment out
the new line and the error is on the commented out line????

***************************************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: // var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
******************************************************************************************The
error is on line 48.How can that be??? It is commented out.The trace
for this page is:_ctl0:ResumeDisplay:blush:bjResumeText
System.Web.UI.WebControls.Label_ctl0:ResumeDisplay:_ctl51
System.Web.UI.LiteralControl_ctl0:ResumeDisplay:blush:bjCoverLetterTextBox
FreeTextBoxControls.FreeTextBox_ctl0:ResumeDisplay:_ctl30
System.Web.UI.LiteralControlIt says that
'ctl0_ResumeDisplay_objResumeText' doesn't exist. I don't getthe
error message if I don't use the <%=...%> format. It doesn't find
it,but I don't get an error message just a null.Thanks,Tom>> -- bruce
in messageas the
post below said, you need the id rendered (control.ClientId).>>>>>>
also the form.elements collection only contains form
controls(input,select and textarea). only form elements have a type and
nameproperty.>>>>>> also as firefox is strict, you need to
specify:>>>>>> document.addForm.elements>>>>>> to find dom objects like
a span or anchor (link), you want to walkchildNodes recursively.>>>>>>>
You're right on the span. I hadn't realized I was using a Label (when
Ichanged it to a textbox it worked fine). But I do need to get
theLabel/Span and my walking the nodes is not working correctly.>>>> I
am doing the following:>>>> alert("length = " +
document.addForm.length);>> for (var i = 0;i<
document.addForm.length;i++)>> {>> alert("inside for loop i = " +
i);>> var e = document.addForm.elements;>> alert("e.type = " +
e.type);>> alert("e.name = " + e.name);>> }>>>> But this doesn't
seem to find the span tag (which has an id). I assume Iam not
following the whole path.>>>> How would I change this so I would find
the span tag?>>>> Thanks,>>>> Tom>>>>> -- bruce (sqlwork.com)>>>>>>
tshad wrote:>>>> In FireFox, the length show 3 so doesn't work at
all.>>>>>>>> Not sure how to get this to work.>>>>>>>> Thanks,>>>>>>>>
messageI have an
aspx window that is calling another window and I am tryingto get a
couple of objects from the opening page. The problem is that Ican't
seem to get anything inside of my form.>>>>>>>>>> I have the following
in my opener page:>>>>>>>>>> <body id="myBody" leftmargin="0"
topmargin="0" marginwidth="0"marginheight="0" runat="server">>>>>>
<form id="addForm" runat="server">>>>>> <asp:label id="theBox" text
= "a test" runat="server"/>>>>>> <asp:placeHolder
ID="thePlaceHolder" runat="server"/>>>>>> </form>>>>>>
</body>>>>>>>>>>> The "thePlaceHolder" object is where I put my User
object.>>>>>>>>>> I am trying to get to some of the objects inside of
this user objectand if I walk the Dom I can see some (but not all the
objects).>>>>>>>>>> I can't even seem to get to the "theBox" object
which is one of thefirst objects in the Dom. I tried to get the object
like this:>>>>>>>>>> function entry()>>>>> {>>>>> alert("On
Entry");>>>>> var theObject =
window.opener.document.getElementById('theBox');>>>>> alert("After
Entry theObject = " + theObject);>>>>>>>>>> alert("length = " +
window.opener.document.addForm.length);>>>>>>>>>> for (var i = 0;i<
window.opener.document.addForm.length;i++)>>>>> {>>>>>
alert("inside for loop i = " + i);>>>>> var e =
window.opener.document.addForm.elements;>>>>> alert("e.type = "
+ e.type);>>>>> alert("e.name = " +
e.name);>>>>> }>>>>> }>>>>>>>>>> theObject ends up being null. If I
move the "theBox" object outsideof the form, it seems to find it
fine.>>>>>>>>>> When I walk the Dom, the length is about 25 and I know
there are about200 objects on the page. Some of the objects are being
shown inside of theUser control - but "theBox" doesn't show at all.
And it is one of the firstones.>>>>>>>>>> The trace shows the first
part of the objects as:>>>>>>>>>> __PAGE
ASP.ResumeSubmittalForm_aspx>>>>> _ctl1
System.Web.UI.LiteralControl>>>>> _ctl2
System.Web.UI.LiteralControl>>>>> MyStyleSheet
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl3
System.Web.UI.LiteralControl>>>>> myBody
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl4
System.Web.UI.LiteralControl>>>>> addForm
System.Web.UI.HtmlControls.HtmlForm>>>>> _ctl5
System.Web.UI.LiteralControl>>>>> theBox
System.Web.UI.WebControls.Label>>>>> _ctl6
System.Web.UI.LiteralControl>>>>> thePlaceHolder
System.Web.UI.WebControls.PlaceHolder>>>>> _ctl0
ASP.mainPage_ascx>>>>>
_ctl0:_ctl2System.Web.UI.ResourceBasedLiteralControl>>>>>
_ctl0:HomeLink System.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl3
System.Web.UI.LiteralControl>>>>>
_ctl0:MyInformationLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl4 System.Web.UI.LiteralControl>>>>>
_ctl0:ResumeLinkSystem.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl5
System.Web.UI.LiteralControl>>>>>
_ctl0:CoverLetterLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl6 System.Web.UI.LiteralControl>>>>>
_ctl0:passportLinkSystem.Web.UI.WebControls.HyperLink>>>>>>>>>> The
Forms collection shows as:>>>>>>>>>> __EVENTTARGET
_ctl0:_ctl1:previewLink>>>>> __EVENTARGUMENT>>>>> __VIEWSTATE
dDwzNj>>>>> _ctl0:_ctl1:resumes 0>>>>> ctl0__ctl1_ResumeText>>>>>
ctl0__ctl1_CoverLetter>>>>> _ctl0:_ctl1:GenderList>>>>>
_ctl0:_ctl1:EthnicityList>>>>> _ctl0:_ctl1:VeteranStatus>>>>>
_sk_scrollkeepervalue 0!0>>>>>>>>>> Where is the "theBox" control and
when walking the Dom it show thelength as 25.>>>>>>>>>> What is going
on?????>>>>>>>>>> Is this a problem with asp.net 1.1????>>>>>>>>>>
Thanks,>>>>>>>>>> Tom>>>>>>>


 
M

Mark Rae [MVP]

Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does.

Not sure about why that is exactly but, to answer your question about
commenting, you need to comment both the client-side *AND* server side
script e.g.

// var toResumeText =
document.forms[0].getElementById('<%//=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
 
T

tshad

Lit said:
use this

var toResumeText = document.getElementById('<%=objResumeText.ClientID%>');

Didn't work in the .aspx page.

Just copied and pasted it in but I get the same error (except it now says
that objResumeText doesn't exist).

Here is the object in the .ascx page:

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><asp:Label ID="objResumeText"
runat="server"/>
<br> <br>
</td>
</tr>

Here is the object in the View Source (after I take the line out so the page
loads correctly).

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><span
id="_ctl0_ResumeDisplay_objResumeText"></span>
<br> <br>
</td>
</tr>

I am getting this error before the function is called as I have at least 3
alert statements before the getElementById statement.

It probably has something to do with the Javascript being in the .aspx page
and objResumeText being in the .ascx page that is being called by the .aspx
page.

But since this is being called onload in the <body> tag, I can't put the
Javascript in the .ascx file (I don't think).

The body tag is:

<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">

and the onload is being set in the Page_Load function:

Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
myBody.Attributes.Add("onLoad","entry()")
Dim pageControl as Control

I finally got it to work by moving the script section over to the .ascx
(User Control) page. I wasn't sure it would work as I thought it may cough
up on the myBody.Attributes.Add("onLoad","entry()") statement in the .aspx
file since now the entry() function is in the .ascx file. I thought it may
say that entry() doesn't exist.

Apparently, that wasn't the case as it works now.

I think it is interesting that

var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');

works in the .aspx file and

var toResumeText = document.getElementById('<%=objResumeText.ClientID%>');

does not.

I am still confused why comments don't work in this case.

Thanks,

Tom
DO NOT USE THIS

_ctl0_ResumeDisplay_objResumeText.ClientID

_ctl0_ResumeDisplay_objResumeText is the ClientID



Lit



tshad said:
tshad said:
tshad,

This is wrong.
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');

it looks like you are getting the ClientId on the clientId

<%=The_ID_Of_Your_Server_Control.ClientId%>

What is the ID of your Label

The asp.net line is:

<asp:Label ID="objResumeText" runat="server"/>

in the View Source it is:

<span id="_ctl0_ResumeDisplay_objResumeText"></span>

Could the error be because the objResumeText is in a User control
(ResumeDisplay)?

I assume that the problem is the User Controls, because I created a Label
on my main page with id of "theLabel" and this worked fine:

var toResumeText = document.getElementById('<%=theLabel.ClientID%>');

Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does. But even if it didn't, the commenting out
should prevent the error. This is the first time I have not been able
comment a line out.

Thanks,

Tom


Thanks,

Tom

if the ServerSide ID of your Label is MyLabel123 then use
<%=MyLabel123.ClientID%> -- verify syntax

Make sure Label is runat="server"

Lit




as i said, you need to use the childNodes, and a span does not have a
type or name property.

var nodes = document.forms[0].childNodes;
for (var i=0; i < nodes.length; ++i)
{
alert("tag: " + node.tagName + " id: " + nodes.id);
}

or lookup the span by id.

var theBox = document.getElementById('<%=theBox.ClientId%>');

I tried that but it gives me an error:

*******************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: // var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
*******************************************************

Here is the code:

var fromResumeText =
window.opener.document.getElementById('ctl0__ctl1_ResumeText');
var fromCoverLetter =
window.opener.document.getElementById('ctl0__ctl1_CoverLetter');
// var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');

I am looking for 2 objects on my opener page and 2 from my current
page. I can find all the objects except the
'ctl0_ResumeDisplay_objResumeText' which is the only object that is an
asp:Label.

This code worked fine except that it didn't find Label objects - it
found the other 3.

This error happened when I added the <%=...%> format.

The interesting thing is that I get the error even when I comment out
the new line and the error is on the commented out line????

***************************************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: // var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
******************************************************************************************The
error is on line 48.How can that be??? It is commented out.The trace
for this page is:_ctl0:ResumeDisplay:blush:bjResumeText
System.Web.UI.WebControls.Label_ctl0:ResumeDisplay:_ctl51
System.Web.UI.LiteralControl_ctl0:ResumeDisplay:blush:bjCoverLetterTextBox
FreeTextBoxControls.FreeTextBox_ctl0:ResumeDisplay:_ctl30
System.Web.UI.LiteralControlIt says that
'ctl0_ResumeDisplay_objResumeText' doesn't exist. I don't getthe
error message if I don't use the <%=...%> format. It doesn't find
it,but I don't get an error message just a null.Thanks,Tom>> -- bruce
(sqlwork.com)>> tshad wrote:>> "bruce barker" <[email protected]>
wrote in messageas
the post below said, you need the id rendered
(control.ClientId).>>>>>> also the form.elements collection only
contains form controls(input,select and textarea). only form elements
have a type and nameproperty.>>>>>> also as firefox is strict, you
need to specify:>>>>>> document.addForm.elements>>>>>> to find dom
objects like a span or anchor (link), you want to walkchildNodes
recursively.>>>>>>> You're right on the span. I hadn't realized I was
using a Label (when Ichanged it to a textbox it worked fine). But I
do need to get theLabel/Span and my walking the nodes is not working
correctly.>>>> I am doing the following:>>>> alert("length = " +
document.addForm.length);>> for (var i = 0;i<
document.addForm.length;i++)>> {>> alert("inside for loop i = " +
i);>> var e = document.addForm.elements;>> alert("e.type = " +
e.type);>> alert("e.name = " + e.name);>> }>>>> But this doesn't
seem to find the span tag (which has an id). I assume Iam not
following the whole path.>>>> How would I change this so I would find
the span tag?>>>> Thanks,>>>> Tom>>>>> -- bruce (sqlwork.com)>>>>>>
tshad wrote:>>>> In FireFox, the length show 3 so doesn't work at
all.>>>>>>>> Not sure how to get this to work.>>>>>>>> Thanks,>>>>>>>>
messageI have an
aspx window that is calling another window and I am tryingto get a
couple of objects from the opening page. The problem is that Ican't
seem to get anything inside of my form.>>>>>>>>>> I have the following
in my opener page:>>>>>>>>>> <body id="myBody" leftmargin="0"
topmargin="0" marginwidth="0"marginheight="0" runat="server">>>>>>
<form id="addForm" runat="server">>>>>> <asp:label id="theBox"
text = "a test" runat="server"/>>>>>> <asp:placeHolder
ID="thePlaceHolder" runat="server"/>>>>>> </form>>>>>>
</body>>>>>>>>>>> The "thePlaceHolder" object is where I put my User
object.>>>>>>>>>> I am trying to get to some of the objects inside of
this user objectand if I walk the Dom I can see some (but not all the
objects).>>>>>>>>>> I can't even seem to get to the "theBox" object
which is one of thefirst objects in the Dom. I tried to get the
object like this:>>>>>>>>>> function entry()>>>>> {>>>>> alert("On
Entry");>>>>> var theObject =
window.opener.document.getElementById('theBox');>>>>> alert("After
Entry theObject = " + theObject);>>>>>>>>>> alert("length = " +
window.opener.document.addForm.length);>>>>>>>>>> for (var i = 0;i<
window.opener.document.addForm.length;i++)>>>>> {>>>>> alert("inside
for loop i = " + i);>>>>> var e =
window.opener.document.addForm.elements;>>>>> alert("e.type = "
+ e.type);>>>>> alert("e.name = " +
e.name);>>>>> }>>>>> }>>>>>>>>>> theObject ends up being null. If I
move the "theBox" object outsideof the form, it seems to find it
fine.>>>>>>>>>> When I walk the Dom, the length is about 25 and I know
there are about200 objects on the page. Some of the objects are being
shown inside of theUser control - but "theBox" doesn't show at all.
And it is one of the firstones.>>>>>>>>>> The trace shows the first
part of the objects as:>>>>>>>>>> __PAGE
ASP.ResumeSubmittalForm_aspx>>>>> _ctl1
System.Web.UI.LiteralControl>>>>> _ctl2
System.Web.UI.LiteralControl>>>>> MyStyleSheet
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl3
System.Web.UI.LiteralControl>>>>> myBody
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl4
System.Web.UI.LiteralControl>>>>> addForm
System.Web.UI.HtmlControls.HtmlForm>>>>> _ctl5
System.Web.UI.LiteralControl>>>>> theBox
System.Web.UI.WebControls.Label>>>>> _ctl6
System.Web.UI.LiteralControl>>>>> thePlaceHolder
System.Web.UI.WebControls.PlaceHolder>>>>> _ctl0
ASP.mainPage_ascx>>>>>
_ctl0:_ctl2System.Web.UI.ResourceBasedLiteralControl>>>>>
_ctl0:HomeLink System.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl3
System.Web.UI.LiteralControl>>>>>
_ctl0:MyInformationLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl4 System.Web.UI.LiteralControl>>>>>
_ctl0:ResumeLinkSystem.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl5
System.Web.UI.LiteralControl>>>>>
_ctl0:CoverLetterLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl6 System.Web.UI.LiteralControl>>>>>
_ctl0:passportLinkSystem.Web.UI.WebControls.HyperLink>>>>>>>>>> The
Forms collection shows as:>>>>>>>>>> __EVENTTARGET
_ctl0:_ctl1:previewLink>>>>> __EVENTARGUMENT>>>>> __VIEWSTATE
dDwzNj>>>>> _ctl0:_ctl1:resumes 0>>>>> ctl0__ctl1_ResumeText>>>>>
ctl0__ctl1_CoverLetter>>>>> _ctl0:_ctl1:GenderList>>>>>
_ctl0:_ctl1:EthnicityList>>>>> _ctl0:_ctl1:VeteranStatus>>>>>
_sk_scrollkeepervalue 0!0>>>>>>>>>> Where is the "theBox" control and
when walking the Dom it show thelength as 25.>>>>>>>>>> What is going
on?????>>>>>>>>>> Is this a problem with asp.net 1.1????>>>>>>>>>>
Thanks,>>>>>>>>>> Tom>>>>>>>


 
T

tshad

Mark Rae said:
Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does.

Not sure about why that is exactly but, to answer your question about
commenting, you need to comment both the client-side *AND* server side
script e.g.

// var toResumeText =
document.forms[0].getElementById('<%//=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

Really?

Why is that? Comments are supposed to be ignored. Lines that are commented
by /* */ could span 20 lines. But if this line is in the commented lines
it will get the error.

What other things cause this problem with comments?

Thanks,

Tom
 
L

Lit

I would delete the label and recreate it.
Something is strange. I don't know why it does not work.

Lit


tshad said:
Lit said:
use this

var toResumeText =
document.getElementById('<%=objResumeText.ClientID%>');

Didn't work in the .aspx page.

Just copied and pasted it in but I get the same error (except it now says
that objResumeText doesn't exist).

Here is the object in the .ascx page:

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><asp:Label ID="objResumeText"
runat="server"/>
<br> <br>
</td>
</tr>

Here is the object in the View Source (after I take the line out so the
page loads correctly).

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><span
id="_ctl0_ResumeDisplay_objResumeText"></span>
<br> <br>
</td>
</tr>

I am getting this error before the function is called as I have at least 3
alert statements before the getElementById statement.

It probably has something to do with the Javascript being in the .aspx
page and objResumeText being in the .ascx page that is being called by the
.aspx page.

But since this is being called onload in the <body> tag, I can't put the
Javascript in the .ascx file (I don't think).

The body tag is:

<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">

and the onload is being set in the Page_Load function:

Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
myBody.Attributes.Add("onLoad","entry()")
Dim pageControl as Control

I finally got it to work by moving the script section over to the .ascx
(User Control) page. I wasn't sure it would work as I thought it may
cough up on the myBody.Attributes.Add("onLoad","entry()") statement in the
.aspx file since now the entry() function is in the .ascx file. I thought
it may say that entry() doesn't exist.

Apparently, that wasn't the case as it works now.

I think it is interesting that

var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');

works in the .aspx file and

var toResumeText = document.getElementById('<%=objResumeText.ClientID%>');

does not.

I am still confused why comments don't work in this case.

Thanks,

Tom
DO NOT USE THIS

_ctl0_ResumeDisplay_objResumeText.ClientID

_ctl0_ResumeDisplay_objResumeText is the ClientID



Lit



tshad said:
tshad,

This is wrong.
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');

it looks like you are getting the ClientId on the clientId

<%=The_ID_Of_Your_Server_Control.ClientId%>

What is the ID of your Label

The asp.net line is:

<asp:Label ID="objResumeText" runat="server"/>

in the View Source it is:

<span id="_ctl0_ResumeDisplay_objResumeText"></span>

Could the error be because the objResumeText is in a User control
(ResumeDisplay)?

I assume that the problem is the User Controls, because I created a
Label on my main page with id of "theLabel" and this worked fine:

var toResumeText = document.getElementById('<%=theLabel.ClientID%>');

Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does. But even if it didn't, the commenting
out should prevent the error. This is the first time I have not been
able comment a line out.

Thanks,

Tom




Thanks,

Tom

if the ServerSide ID of your Label is MyLabel123 then use
<%=MyLabel123.ClientID%> -- verify syntax

Make sure Label is runat="server"

Lit




as i said, you need to use the childNodes, and a span does not have
a type or name property.

var nodes = document.forms[0].childNodes;
for (var i=0; i < nodes.length; ++i)
{
alert("tag: " + node.tagName + " id: " + nodes.id);
}

or lookup the span by id.

var theBox = document.getElementById('<%=theBox.ClientId%>');

I tried that but it gives me an error:

*******************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: // var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
*******************************************************

Here is the code:

var fromResumeText =
window.opener.document.getElementById('ctl0__ctl1_ResumeText');
var fromCoverLetter =
window.opener.document.getElementById('ctl0__ctl1_CoverLetter');
// var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');

I am looking for 2 objects on my opener page and 2 from my current
page. I can find all the objects except the
'ctl0_ResumeDisplay_objResumeText' which is the only object that is
an asp:Label.

This code worked fine except that it didn't find Label objects - it
found the other 3.

This error happened when I added the <%=...%> format.

The interesting thing is that I get the error even when I comment out
the new line and the error is on the commented out line????

***************************************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: // var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
******************************************************************************************The
error is on line 48.How can that be??? It is commented out.The trace
for this page is:_ctl0:ResumeDisplay:blush:bjResumeText
System.Web.UI.WebControls.Label_ctl0:ResumeDisplay:_ctl51
System.Web.UI.LiteralControl_ctl0:ResumeDisplay:blush:bjCoverLetterTextBox
FreeTextBoxControls.FreeTextBox_ctl0:ResumeDisplay:_ctl30
System.Web.UI.LiteralControlIt says that
'ctl0_ResumeDisplay_objResumeText' doesn't exist. I don't getthe
error message if I don't use the <%=...%> format. It doesn't find
it,but I don't get an error message just a null.Thanks,Tom>> -- bruce
(sqlwork.com)>> tshad wrote:>> "bruce barker" <[email protected]>
wrote in messageas
the post below said, you need the id rendered
(control.ClientId).>>>>>> also the form.elements collection only
contains form controls(input,select and textarea). only form elements
have a type and nameproperty.>>>>>> also as firefox is strict, you
need to specify:>>>>>> document.addForm.elements>>>>>> to find dom
objects like a span or anchor (link), you want to walkchildNodes
recursively.>>>>>>> You're right on the span. I hadn't realized I
was using a Label (when Ichanged it to a textbox it worked fine).
But I do need to get theLabel/Span and my walking the nodes is not
working correctly.>>>> I am doing the following:>>>> alert("length =
" + document.addForm.length);>> for (var i = 0;i<
document.addForm.length;i++)>> {>> alert("inside for loop i = " +
i);>> var e = document.addForm.elements;>> alert("e.type = " +
e.type);>> alert("e.name = " + e.name);>> }>>>> But this doesn't
seem to find the span tag (which has an id). I assume Iam not
following the whole path.>>>> How would I change this so I would find
the span tag?>>>> Thanks,>>>> Tom>>>>> -- bruce (sqlwork.com)>>>>>>
tshad wrote:>>>> In FireFox, the length show 3 so doesn't work at
all.>>>>>>>> Not sure how to get this to work.>>>>>>>>
messageI have an
aspx window that is calling another window and I am tryingto get a
couple of objects from the opening page. The problem is that Ican't
seem to get anything inside of my form.>>>>>>>>>> I have the
following in my opener page:>>>>>>>>>> <body id="myBody"
leftmargin="0" topmargin="0" marginwidth="0"marginheight="0"
runat="server">>>>>> <form id="addForm" runat="server">>>>>>
<asp:label id="theBox" text = "a test" runat="server"/>>>>>>
<asp:placeHolder ID="thePlaceHolder" runat="server"/>>>>>>
</form>>>>>> </body>>>>>>>>>>> The "thePlaceHolder" object is where I
put my User object.>>>>>>>>>> I am trying to get to some of the
objects inside of this user objectand if I walk the Dom I can see
some (but not all the objects).>>>>>>>>>> I can't even seem to get to
the "theBox" object which is one of thefirst objects in the Dom. I
tried to get the object like this:>>>>>>>>>> function entry()>>>>>
{>>>>> alert("On Entry");>>>>> var theObject =
window.opener.document.getElementById('theBox');>>>>> alert("After
Entry theObject = " + theObject);>>>>>>>>>> alert("length = " +
window.opener.document.addForm.length);>>>>>>>>>> for (var i = 0;i<
window.opener.document.addForm.length;i++)>>>>> {>>>>> alert("inside
for loop i = " + i);>>>>> var e =
window.opener.document.addForm.elements;>>>>> alert("e.type =
" + e.type);>>>>> alert("e.name = " +
e.name);>>>>> }>>>>> }>>>>>>>>>> theObject ends up being null. If I
move the "theBox" object outsideof the form, it seems to find it
fine.>>>>>>>>>> When I walk the Dom, the length is about 25 and I
know there are about200 objects on the page. Some of the objects are
being shown inside of theUser control - but "theBox" doesn't show at
all. And it is one of the firstones.>>>>>>>>>> The trace shows the
first part of the objects as:>>>>>>>>>> __PAGE
ASP.ResumeSubmittalForm_aspx>>>>> _ctl1
System.Web.UI.LiteralControl>>>>> _ctl2
System.Web.UI.LiteralControl>>>>> MyStyleSheet
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl3
System.Web.UI.LiteralControl>>>>> myBody
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl4
System.Web.UI.LiteralControl>>>>> addForm
System.Web.UI.HtmlControls.HtmlForm>>>>> _ctl5
System.Web.UI.LiteralControl>>>>> theBox
System.Web.UI.WebControls.Label>>>>> _ctl6
System.Web.UI.LiteralControl>>>>> thePlaceHolder
System.Web.UI.WebControls.PlaceHolder>>>>> _ctl0
ASP.mainPage_ascx>>>>>
_ctl0:_ctl2System.Web.UI.ResourceBasedLiteralControl>>>>>
_ctl0:HomeLink System.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl3
System.Web.UI.LiteralControl>>>>>
_ctl0:MyInformationLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl4 System.Web.UI.LiteralControl>>>>>
_ctl0:ResumeLinkSystem.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl5
System.Web.UI.LiteralControl>>>>>
_ctl0:CoverLetterLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl6 System.Web.UI.LiteralControl>>>>>
_ctl0:passportLinkSystem.Web.UI.WebControls.HyperLink>>>>>>>>>> The
Forms collection shows as:>>>>>>>>>> __EVENTTARGET
_ctl0:_ctl1:previewLink>>>>> __EVENTARGUMENT>>>>> __VIEWSTATE
dDwzNj>>>>> _ctl0:_ctl1:resumes 0>>>>> ctl0__ctl1_ResumeText>>>>>
ctl0__ctl1_CoverLetter>>>>> _ctl0:_ctl1:GenderList>>>>>
_ctl0:_ctl1:EthnicityList>>>>> _ctl0:_ctl1:VeteranStatus>>>>>
_sk_scrollkeepervalue 0!0>>>>>>>>>> Where is the "theBox" control and
when walking the Dom it show thelength as 25.>>>>>>>>>> What is going
on?????>>>>>>>>>> Is this a problem with asp.net 1.1????>>>>>>>>>>
Thanks,>>>>>>>>>> Tom>>>>>>>


 
T

tshad

Lit said:
I would delete the label and recreate it.
Something is strange. I don't know why it does not work.

You're right.

I deleted and recreated the Label and it worked. I think I may have been
missing the "__" at the beginning of the ID.

I did find that the following getElementByID format is the one you have to
use if the control is on a different page. This means you would need to
look at the View Source to find out the actual ID. This is what
<%=objResumeText.ClientID%> does for you.

document.getElementById('_ctl0_ResumeDisplay_objResumeText');

The following getElementByID is better since you don't need to know what the
ID will render to. But the control MUST be on the same page or User
Control. If you are using multiple controls, this wouldn't work. You will
get an "objResumeText" does not exist - even though it will on the full page
after rendering.

document.getElementById('<%=objResumeText.ClientID%>');

Thanks for all the help,

Tom
Lit


tshad said:
Lit said:
use this

var toResumeText =
document.getElementById('<%=objResumeText.ClientID%>');

Didn't work in the .aspx page.

Just copied and pasted it in but I get the same error (except it now says
that objResumeText doesn't exist).

Here is the object in the .ascx page:

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><asp:Label ID="objResumeText"
runat="server"/>
<br> <br>
</td>
</tr>

Here is the object in the View Source (after I take the line out so the
page loads correctly).

<tr bgcolor="#F3F3F3">
<td><p style="margin-left:10px"><span
id="_ctl0_ResumeDisplay_objResumeText"></span>
<br> <br>
</td>
</tr>

I am getting this error before the function is called as I have at least
3 alert statements before the getElementById statement.

It probably has something to do with the Javascript being in the .aspx
page and objResumeText being in the .ascx page that is being called by
the .aspx page.

But since this is being called onload in the <body> tag, I can't put the
Javascript in the .ascx file (I don't think).

The body tag is:

<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">

and the onload is being set in the Page_Load function:

Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
myBody.Attributes.Add("onLoad","entry()")
Dim pageControl as Control

I finally got it to work by moving the script section over to the .ascx
(User Control) page. I wasn't sure it would work as I thought it may
cough up on the myBody.Attributes.Add("onLoad","entry()") statement in
the .aspx file since now the entry() function is in the .ascx file. I
thought it may say that entry() doesn't exist.

Apparently, that wasn't the case as it works now.

I think it is interesting that

var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');

works in the .aspx file and

var toResumeText =
document.getElementById('<%=objResumeText.ClientID%>');

does not.

I am still confused why comments don't work in this case.

Thanks,

Tom
DO NOT USE THIS

_ctl0_ResumeDisplay_objResumeText.ClientID

_ctl0_ResumeDisplay_objResumeText is the ClientID



Lit



tshad,

This is wrong.
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');

it looks like you are getting the ClientId on the clientId

<%=The_ID_Of_Your_Server_Control.ClientId%>

What is the ID of your Label

The asp.net line is:

<asp:Label ID="objResumeText" runat="server"/>

in the View Source it is:

<span id="_ctl0_ResumeDisplay_objResumeText"></span>

Could the error be because the objResumeText is in a User control
(ResumeDisplay)?

I assume that the problem is the User Controls, because I created a
Label on my main page with id of "theLabel" and this worked fine:

var toResumeText = document.getElementById('<%=theLabel.ClientID%>');

Maybe the problem is related to the fact that you cannot even comment
problem line without getting an error which makes no sense to me.

I tried:

// var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

and

/* var toResumeText =
document.forms[0].getElementById('<%=_ctl0_ResumeDisplay_objResumeText.ClientID%>');
*/

Both still give me the error that _ctl0_ResumeDisplay_objResumeText
doesn't exist - which it does. But even if it didn't, the commenting
out should prevent the error. This is the first time I have not been
able comment a line out.

Thanks,

Tom




Thanks,

Tom

if the ServerSide ID of your Label is MyLabel123 then use
<%=MyLabel123.ClientID%> -- verify syntax

Make sure Label is runat="server"

Lit




as i said, you need to use the childNodes, and a span does not have
a type or name property.

var nodes = document.forms[0].childNodes;
for (var i=0; i < nodes.length; ++i)
{
alert("tag: " + node.tagName + " id: " + nodes.id);
}

or lookup the span by id.

var theBox = document.getElementById('<%=theBox.ClientId%>');

I tried that but it gives me an error:

*******************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: // var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
*******************************************************

Here is the code:

var fromResumeText =
window.opener.document.getElementById('ctl0__ctl1_ResumeText');
var fromCoverLetter =
window.opener.document.getElementById('ctl0__ctl1_CoverLetter');
// var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');

I am looking for 2 objects on my opener page and 2 from my current
page. I can find all the objects except the
'ctl0_ResumeDisplay_objResumeText' which is the only object that is
an asp:Label.

This code worked fine except that it didn't find Label objects - it
found the other 3.

This error happened when I added the <%=...%> format.

The interesting thing is that I get the error even when I comment
out the new line and the error is on the commented out line????

***************************************************************************
Compiler Error Message: BC30451: Name
'ctl0_ResumeDisplay_objResumeText' is not declared.

Source Error:

Line 47: var toResumeText =
document.getElementById('ctl0_ResumeDisplay_objResumeText');
Line 48: // var toResumeText =
document.getElementById('<%=ctl0_ResumeDisplay_objResumeText.ClientID%>');
Line 50: var toCoverLetter =
document.getElementById('ctl0_ResumeDisplay_objCoverLetterTextBox');
******************************************************************************************The
error is on line 48.How can that be??? It is commented out.The
trace for this page is:_ctl0:ResumeDisplay:blush:bjResumeText
System.Web.UI.WebControls.Label_ctl0:ResumeDisplay:_ctl51
System.Web.UI.LiteralControl_ctl0:ResumeDisplay:blush:bjCoverLetterTextBox
FreeTextBoxControls.FreeTextBox_ctl0:ResumeDisplay:_ctl30
System.Web.UI.LiteralControlIt says that
'ctl0_ResumeDisplay_objResumeText' doesn't exist. I don't getthe
error message if I don't use the <%=...%> format. It doesn't find
it,but I don't get an error message just a null.Thanks,Tom>> --
bruce (sqlwork.com)>> tshad wrote:>> "bruce barker"
messageas the
post below said, you need the id rendered (control.ClientId).>>>>>>
also the form.elements collection only contains form
controls(input,select and textarea). only form elements have a type
and nameproperty.>>>>>> also as firefox is strict, you need to
specify:>>>>>> document.addForm.elements>>>>>> to find dom objects
like a span or anchor (link), you want to walkchildNodes
recursively.>>>>>>> You're right on the span. I hadn't realized I
was using a Label (when Ichanged it to a textbox it worked fine).
But I do need to get theLabel/Span and my walking the nodes is not
working correctly.>>>> I am doing the following:>>>> alert("length
= " + document.addForm.length);>> for (var i = 0;i<
document.addForm.length;i++)>> {>> alert("inside for loop i = " +
i);>> var e = document.addForm.elements;>> alert("e.type = " +
e.type);>> alert("e.name = " + e.name);>> }>>>> But this doesn't
seem to find the span tag (which has an id). I assume Iam not
following the whole path.>>>> How would I change this so I would
find the span tag?>>>> Thanks,>>>> Tom>>>>> -- bruce
(sqlwork.com)>>>>>> tshad wrote:>>>> In FireFox, the length show 3
so doesn't work at all.>>>>>>>> Not sure how to get this to
in messageI have
an aspx window that is calling another window and I am tryingto get
a couple of objects from the opening page. The problem is that
Ican't seem to get anything inside of my form.>>>>>>>>>> I have the
following in my opener page:>>>>>>>>>> <body id="myBody"
leftmargin="0" topmargin="0" marginwidth="0"marginheight="0"
runat="server">>>>>> <form id="addForm" runat="server">>>>>>
<asp:label id="theBox" text = "a test" runat="server"/>>>>>>
<asp:placeHolder ID="thePlaceHolder" runat="server"/>>>>>>
</form>>>>>> </body>>>>>>>>>>> The "thePlaceHolder" object is where
I put my User object.>>>>>>>>>> I am trying to get to some of the
objects inside of this user objectand if I walk the Dom I can see
some (but not all the objects).>>>>>>>>>> I can't even seem to get
to the "theBox" object which is one of thefirst objects in the Dom.
I tried to get the object like this:>>>>>>>>>> function entry()>>>>>
{>>>>> alert("On Entry");>>>>> var theObject =
window.opener.document.getElementById('theBox');>>>>> alert("After
Entry theObject = " + theObject);>>>>>>>>>> alert("length = " +
window.opener.document.addForm.length);>>>>>>>>>> for (var i = 0;i<
window.opener.document.addForm.length;i++)>>>>> {>>>>> alert("inside
for loop i = " + i);>>>>> var e =
window.opener.document.addForm.elements;>>>>> alert("e.type =
" + e.type);>>>>> alert("e.name = " +
e.name);>>>>> }>>>>> }>>>>>>>>>> theObject ends up being null. If I
move the "theBox" object outsideof the form, it seems to find it
fine.>>>>>>>>>> When I walk the Dom, the length is about 25 and I
know there are about200 objects on the page. Some of the objects are
being shown inside of theUser control - but "theBox" doesn't show at
all. And it is one of the firstones.>>>>>>>>>> The trace shows the
first part of the objects as:>>>>>>>>>> __PAGE
ASP.ResumeSubmittalForm_aspx>>>>> _ctl1
System.Web.UI.LiteralControl>>>>> _ctl2
System.Web.UI.LiteralControl>>>>> MyStyleSheet
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl3
System.Web.UI.LiteralControl>>>>> myBody
System.Web.UI.HtmlControls.HtmlGenericControl>>>>> _ctl4
System.Web.UI.LiteralControl>>>>> addForm
System.Web.UI.HtmlControls.HtmlForm>>>>> _ctl5
System.Web.UI.LiteralControl>>>>> theBox
System.Web.UI.WebControls.Label>>>>> _ctl6
System.Web.UI.LiteralControl>>>>> thePlaceHolder
System.Web.UI.WebControls.PlaceHolder>>>>> _ctl0
ASP.mainPage_ascx>>>>>
_ctl0:_ctl2System.Web.UI.ResourceBasedLiteralControl>>>>>
_ctl0:HomeLink System.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl3
System.Web.UI.LiteralControl>>>>>
_ctl0:MyInformationLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl4 System.Web.UI.LiteralControl>>>>>
_ctl0:ResumeLinkSystem.Web.UI.WebControls.HyperLink>>>>> _ctl0:_ctl5
System.Web.UI.LiteralControl>>>>>
_ctl0:CoverLetterLinkSystem.Web.UI.WebControls.HyperLink>>>>>
_ctl0:_ctl6 System.Web.UI.LiteralControl>>>>>
_ctl0:passportLinkSystem.Web.UI.WebControls.HyperLink>>>>>>>>>> The
Forms collection shows as:>>>>>>>>>> __EVENTTARGET
_ctl0:_ctl1:previewLink>>>>> __EVENTARGUMENT>>>>> __VIEWSTATE
dDwzNj>>>>> _ctl0:_ctl1:resumes 0>>>>> ctl0__ctl1_ResumeText>>>>>
ctl0__ctl1_CoverLetter>>>>> _ctl0:_ctl1:GenderList>>>>>
_ctl0:_ctl1:EthnicityList>>>>> _ctl0:_ctl1:VeteranStatus>>>>>
_sk_scrollkeepervalue 0!0>>>>>>>>>> Where is the "theBox" control
and when walking the Dom it show thelength as 25.>>>>>>>>>> What is
going on?????>>>>>>>>>> Is this a problem with asp.net
1.1????>>>>>>>>>> Thanks,>>>>>>>>>> Tom>>>>>>>


 
M

Mark Rae [MVP]

Not sure about why that is exactly but, to answer your question about
commenting, you need to comment both the client-side *AND* server side
script e.g.

// var toResumeText =
document.forms[0].getElementById('<%//=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

Really?

Why is that? Comments are supposed to be ignored. Lines that are
commented by /* */ could span 20 lines.

<%=...%> basically say "inject a string literal into the HTML markup" - it
has no concept of whether the string that it's injecting resides within a
commented block of JavaScript or not...
But if this line is in the commented lines it will get the error.

That's right - so comment it out and you won't...
 
T

tshad

Mark Rae said:
Not sure about why that is exactly but, to answer your question about
commenting, you need to comment both the client-side *AND* server side
script e.g.

// var toResumeText =
document.forms[0].getElementById('<%//=_ctl0_ResumeDisplay_objResumeText.ClientID%>');

Really?

Why is that? Comments are supposed to be ignored. Lines that are
commented by /* */ could span 20 lines.

<%=...%> basically say "inject a string literal into the HTML markup" - it
has no concept of whether the string that it's injecting resides within a
commented block of JavaScript or not...

Is this the only construct that causes this problem?

Thanks,

Tom
 
T

tshad

Mark Rae said:
I'm not sure what "problem" you're talking about - this is totally
expected behaviour...

It may be expected behavior to you, but I had never heard of it. I have
been programming for years and a comment is a comment. Anything inside a
comment tag, regardless of language, is ignored.

Apparently that is not the case with the <%=...%> construct.

What you are saying is that comments are only partially comments. If they
have certain characters in them, then they aren't???

You can normally, in other languages (of course HTML is not really a
language), comment whole sections of code for explanations, debugging or
just to be able to use later.

Tom
 

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

Top