473,396 Members | 2,108 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,396 software developers and data experts.

why does this code return an empty Alert window?

Hi,

This code produces an empty Alert window. No error.
How to get the value into the Alert window?

Thanks
Phil

aspx file (content page):
------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
asp:Label ID="Label1" runat="server"></asp:Label>

<asp:Button ID="Button1" runat="server" OnClientClick="test()" />
<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById('<%=label1.ClientID%>').in nerText;
alert(x)
}
</script>
</asp:Content>
code-behind:
-----------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = "Alle velden moeten ingevuld zijn"
End sub
Mar 8 '07 #1
6 1381
The label has no text. I tried it - copied and pasted, exactly, except for
adding a "<" bracket in froont of the label, and adding a text property to
it. It worked just fine for me, then.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Phil" <ss*******@fff.dfwrote in message
news:u2*************@TK2MSFTNGP06.phx.gbl...
Hi,

This code produces an empty Alert window. No error.
How to get the value into the Alert window?

Thanks
Phil

aspx file (content page):
------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
asp:Label ID="Label1" runat="server"></asp:Label>

<asp:Button ID="Button1" runat="server" OnClientClick="test()" />
<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById('<%=label1.ClientID%>').in nerText;
alert(x)
}
</script>
</asp:Content>
code-behind:
-----------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = "Alle velden moeten ingevuld zijn"
End sub


Mar 8 '07 #2
Jan
Hi David. Thanks for repying, but i really don't understand what you mean.
Can you tell me what i have to change in my code?
Thanks
"David Wier" <da********@noSpamhotmail.comschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
The label has no text. I tried it - copied and pasted, exactly, except for
adding a "<" bracket in froont of the label, and adding a text property to
it. It worked just fine for me, then.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Phil" <ss*******@fff.dfwrote in message
news:u2*************@TK2MSFTNGP06.phx.gbl...
>Hi,

This code produces an empty Alert window. No error.
How to get the value into the Alert window?

Thanks
Phil

aspx file (content page):
------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
asp:Label ID="Label1" runat="server"></asp:Label>

<asp:Button ID="Button1" runat="server" OnClientClick="test()" />
<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById('<%=label1.ClientID%>').in nerText;
alert(x)
}
</script>
</asp:Content>
code-behind:
-----------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = "Alle velden moeten ingevuld zijn"
End sub



Mar 8 '07 #3
<asp:Label ID="Label1" Text="My Text is Here" runat="server"></asp:Label>

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Jan" <uu*****@fff.tywrote in message
news:u7*************@TK2MSFTNGP04.phx.gbl...
Hi David. Thanks for repying, but i really don't understand what you mean.
Can you tell me what i have to change in my code?
Thanks
"David Wier" <da********@noSpamhotmail.comschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
The label has no text. I tried it - copied and pasted, exactly, except
for
adding a "<" bracket in froont of the label, and adding a text property
to
it. It worked just fine for me, then.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Phil" <ss*******@fff.dfwrote in message
news:u2*************@TK2MSFTNGP06.phx.gbl...
Hi,

This code produces an empty Alert window. No error.
How to get the value into the Alert window?

Thanks
Phil

aspx file (content page):
------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
asp:Label ID="Label1" runat="server"></asp:Label>

<asp:Button ID="Button1" runat="server" OnClientClick="test()" />
<script language="javascript" type="text/javascript">
function test()
{
var x = document.getElementById('<%=label1.ClientID%>').in nerText;
alert(x)
}
</script>
</asp:Content>
code-behind:
-----------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = "Alle velden moeten ingevuld zijn"
End sub



Mar 8 '07 #4
"Jan" <uu*****@fff.tywrote in message
news:u7*************@TK2MSFTNGP04.phx.gbl...
Can you tell me what i have to change in my code?
<asp:Label ID="Label1" runat="server" Text="Hello world!" />
Mar 8 '07 #5
Ok, thanks, but could you tell me why it doesn't work programmatically like
this:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click Label1.Text = "Hello World"
End sub

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:OW**************@TK2MSFTNGP05.phx.gbl...
"Jan" <uu*****@fff.tywrote in message
news:u7*************@TK2MSFTNGP04.phx.gbl...
>Can you tell me what i have to change in my code?

<asp:Label ID="Label1" runat="server" Text="Hello world!" />

Mar 8 '07 #6
It's because the ClientClick will be executed first, and at that moment, the
value is not yet put into 'text' of the label

"Phil" <uu*****@fff.tyschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Ok, thanks, but could you tell me why it doesn't work programmatically
like this:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click Label1.Text = "Hello World"
End sub

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:OW**************@TK2MSFTNGP05.phx.gbl...
>"Jan" <uu*****@fff.tywrote in message
news:u7*************@TK2MSFTNGP04.phx.gbl...
>>Can you tell me what i have to change in my code?

<asp:Label ID="Label1" runat="server" Text="Hello world!" />


Mar 8 '07 #7

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

Similar topics

4
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
9
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
17
by: radhikams | last post by:
Hi I want to create a drag drop tool box using javascript... Can anyone please guide me in this regard Thanks
8
by: knkk | last post by:
Instead of an id getting its innerHTML changed, the entire page is getting refreshed with this function of mine (you may want to look just at the end of the function where there's an alert): ...
1
by: sva0008 | last post by:
i have a auto suggest script that does not work in firefox , works great on IE. /******************************************************* AutoSuggest - a javascript automatic text input...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.