473,395 Members | 1,466 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.

undefined value in Alert window

Hi,

The Alert window appears but the value is "undefined".
I tried two ways
What don't i see here?
Thanks
Phil

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body<form id="form1" runat="server">
<asp:Label ID="label1" runat="server" text="ok" Font-Bold="True"
forecolor="lightsteelblue"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClientClick="test()" />

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("label1").text;
//var x = document.getElementById('<%=label1.ClientID%>').te xt;
doesn't work
alert(x)
}
</script</form</body></html>
Mar 8 '07 #1
4 1670
Phil wrote on 08 mrt 2007 in microsoft.public.scripting.jscript:
Hi,

The Alert window appears but the value is "undefined".
I tried two ways
What don't i see here?
Thanks
Phil

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body<form id="form1" runat="server">
<asp:Label ID="label1" runat="server" text="ok" Font-Bold="True"
forecolor="lightsteelblue"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClientClick="test()" />

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("label1").text;
//var x = document.getElementById('<%=label1.ClientID%>').te xt;
doesn't work
alert(x)
}
</script</form</body></html>
..text is not a DOM extention, perhaps .value.

However perhaps better ask in a dotnet group.

<microsoft.public.dotnet.framework.aspnet>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 8 '07 #2
Label (rendered as <SPANat client) does not have text property at
client-side dom. What if you write for example:

var x = document.getElementById("label1").innerText;

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Phil" <ph**@sgnomail.dkwrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
Hi,

The Alert window appears but the value is "undefined".
I tried two ways
What don't i see here?
Thanks
Phil

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body<form id="form1" runat="server">
<asp:Label ID="label1" runat="server" text="ok" Font-Bold="True"
forecolor="lightsteelblue"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClientClick="test()" />

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("label1").text;
//var x = document.getElementById('<%=label1.ClientID%>').te xt; doesn't
work
alert(x)
}
</script</form</body></html>
Mar 8 '07 #3

"Phil" <ph**@sgnomail.dkwrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
Hi,

The Alert window appears but the value is "undefined".
I tried two ways
What don't i see here?
Thanks
Phil

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body<form id="form1" runat="server">
<asp:Label ID="label1" runat="server" text="ok" Font-Bold="True"
forecolor="lightsteelblue"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClientClick="test()" />

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("label1").text;
//var x = document.getElementById('<%=label1.ClientID%>').te xt;
doesn't work
alert(x)
}
</script</form</body></html>

I'm not up on ASP.NET but the first thing I would check is whether the
ID="label1" actually ends up on an element in the output HTML. Use view
source in your browser and do a text search.

My guess is that it isn't and that you need to repost to
microsoft.public.dotnet.framework.aspnet to get someone to explain.
Mar 8 '07 #4
Thanks

"Anthony Jones" <An*@yadayadayada.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>
"Phil" <ph**@sgnomail.dkwrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
>Hi,

The Alert window appears but the value is "undefined".
I tried two ways
What don't i see here?
Thanks
Phil

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body<form id="form1" runat="server">
<asp:Label ID="label1" runat="server" text="ok" Font-Bold="True"
forecolor="lightsteelblue"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClientClick="test()" />

<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById("label1").text;
//var x = document.getElementById('<%=label1.ClientID%>').te xt;
doesn't work
alert(x)
}
</script</form</body></html>


I'm not up on ASP.NET but the first thing I would check is whether the
ID="label1" actually ends up on an element in the output HTML. Use view
source in your browser and do a text search.

My guess is that it isn't and that you need to repost to
microsoft.public.dotnet.framework.aspnet to get someone to explain.


Mar 8 '07 #5

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

Similar topics

13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
1
by: Silver Arrow | last post by:
Iframe ReturnValue returns undefined if domains are not the same I am using a modal window and an iFrame to try and pull a return value back. IMPORTANT : I am doing this across domains. Main...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
3
by: jimmygoogle | last post by:
I posted earlier with a scope problem. I think I resolved it in IE but in Firefox it still exists. Anyone have any ideas/experience with this? I attached my code sorry it is so long. You can...
17
by: yb | last post by:
Hi, Looking for clarification of undefined variables vs. error in JavaScript code. e.g. <script> alert( z ); // this will be an error, i.e. an exception </script>
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
5
by: Jason | last post by:
Hello, I am trying to dynamically create a table, then set its <td>'s onclick: var table = document.createElement("table"); var row = table.insertRow(-1); var td = row.insertCell(-1);...
14
rrocket
by: rrocket | last post by:
I am passing a value through query string to a popup and then trying to pass it back to the main page... I store the value in a hidden input box <input type="text" name="FromZip" id="FromZip"...
3
by: blackrunner | last post by:
ERROR in my Query?! ERROR: Element GESCHLECHT is undefined in FORM. i think everything ok. Maby somebody can help me here Element GESCHLECHT is undefined in FORM. The error occurred...
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.