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

newb event attempt.

Hello,

two questions about the following code (.aspx file):

Why doesn't the 'Text' property of control 'Label1' get changed in the
function 'SetLabelText()'?
How do I trigger the 'SetLabelText()' function when the mouse moves over the
label control? The line code as below does not function.

Thanks.

<html>
<head>
<script language="VB" runat="server">
Sub SetLabelText()
Label1.Text &= "SetLabelText"
Response.Write ("<br>Hallo")
End Sub
Sub Page_Load(sender As Object, e As EventArgs)
TextBox1.Attributes("onmouseover") = "javascript:alert('Hello!
mouse is over textbox!!')"
Label1.Attributes("onmouseover") = "<% SetLabelText() %>"
End Sub
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54 Text="Move mouse over textbox to
trigger onmouseover event." runat="server"/>
<asp:label id="Label1" runat="server" Text="TESTING" />
<% SetLabelText() %>
</form>
</body>
</html>
Nov 19 '05 #1
1 1084
There is a difference between server side and client side events. You're
on the right track for your client side events (with alerts and onmouseover,
etc), but your server side code is in VB.NET. That isn't javascript and it
only runs on the server. It runs on the server a as result of a postback.
So you'd need to either have a button and have a server-side click event
for the button at which time you can set the label's text or you can do this
work in Page_Load which is called for every request to the server. In Page_Load
you can identify a GET vs a POST via the IsPostBack property.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hello,

two questions about the following code (.aspx file):

Why doesn't the 'Text' property of control 'Label1' get changed in the
function 'SetLabelText()'?
How do I trigger the 'SetLabelText()' function when the mouse moves
over the
label control? The line code as below does not function.
Thanks.

<html>
<head>
<script language="VB" runat="server">
Sub SetLabelText()
Label1.Text &= "SetLabelText"
Response.Write ("<br>Hallo")
End Sub
Sub Page_Load(sender As Object, e As EventArgs)
TextBox1.Attributes("onmouseover") =
"javascript:alert('Hello!
mouse is over textbox!!')"
Label1.Attributes("onmouseover") = "<% SetLabelText() %>"
End Sub
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54 Text="Move mouse over textbox
to
trigger onmouseover event." runat="server"/>
<asp:label id="Label1" runat="server" Text="TESTING" />
<% SetLabelText() %>
</form>
</body>
</html>


Nov 19 '05 #2

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

Similar topics

1
by: HateSpam | last post by:
Using Visual Studio .NET version of Visual Basic. I am defining a class that has, as a member, an array of another user-defined class. private mBoard as CBoardPosition() The problem comes...
24
by: Apotheosis | last post by:
The problem professor gave us is: Write a program which reads two integer values. If the first is less than the second, print the message "up". If the second is less than the first, print the...
5
by: JaD | last post by:
I am trying to understand events and delegates which is confusing me. Okay I have a user control that derives from a GroupBox called (MyPanel) I added this: public delegate void Collapsed();...
1
by: :\\\\derian | last post by:
Hi guys, Background: VB.net developer Question: Can i add and access an unmanaged COM dll to my asp.net project? Previous Attempt: I added a reference to the DLL in the references...
6
by: tommydogs | last post by:
I am just starting out with AxWebBrowser and need help with a simple application. I just want to navigate to a web page, then read in source code. Here's what I have so far: Private Sub...
5
by: Richard Shewmaker | last post by:
Hi. I've been using CSS for basic stuff, mostly concerning fonts. I want to get going with using CSS fully. Two days ago I purchased O'Reilly's "Cascading Style Sheets" and "CSS Cookbook." I've...
15
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
1
by: NachosRancheros | last post by:
Ok so I just started to program with Python about a week ago and I am trying to make a program that will take the path of a file and a shortcut command and save it to a text file. Eventually I want...
2
by: Carl | last post by:
I'm new to C#, and I have only limited programming experience. I've been doing the video tutorials at MS's website, and they're very helpful, but I decided to experiment with GDI+ and have gotten...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.