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
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,
Tomif 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:ResumeDisplaybjResumeText
System.Web.UI.WebControls.Label_ctl0:ResumeDisplay:_ctl51
System.Web.UI.LiteralControl_ctl0:ResumeDisplaybjCoverLetterTextBox
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"/>>>>>> <asplaceHolder
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>>>>>
_ctl0assportLinkSystem.Web.UI.WebControls.HyperLink>>>>>>>>>> The
Forms collection shows as:>>>>>>>>>> __EVENTTARGET
_ctl0:_ctl1reviewLink>>>>> __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>>>>>>>