473,396 Members | 1,938 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.

How to make control visible/invisible on mouseover.

I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's picture,
and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!
Nov 19 '05 #1
6 14660
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!

Nov 19 '05 #2
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!

Nov 19 '05 #3
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the mouse
over the button.

I haven't gotten any other suggestions. I wonder if it's possible to write
the routine I want in VB script instead of java? Is it any easier to access
controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!


Nov 19 '05 #4
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id (the
name of the textbox appended to the user control). This might be what's
happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!



Nov 19 '05 #5
Thanks, good suggestion!

Here's what I've tried, what worked and what didn't:

First, there is a panel on the page, "Panel1" if I set it's CssClass to
"vs1" it is visible. If I set it to "vs2" it is invisible. I've confirmed
this several times.

this worked:
sPic3 = "family/purchase/images/portrait_navs/" & sTitle &
"3.gif"
iBut.Attributes.Add("onMouseOver", "this.src='" & sPic3 & "'")

This gave me a script error: (tried with and without the return false):
script = "document.GetElementByID('panel1').className =
'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

This also gave me a script error:
script = "document.getElementById('" & Panel1.ClientID &
"').className = 'vs1'; "
iBut.Attributes.Add("onMouseOver", script)

As an aside, setting the panel visible/invisible is a fall back. What I
would REALLY want to do is set the text of a label to any one of 15
different values, depending on what button the mouse is rolling over. Also
I would want to set the image for an image control at the same time. But if
I can't do that, then I thought I would pre-set up 15 different panels with
the values already filled in, and just make one visible at the rollover.

---Selden


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id (the
name of the textbox appended to the user control). This might be
what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the
Imagebutton's picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!



Nov 19 '05 #6
I also found another project where something like this is working, so I
copied that script but it wasn't working for me.

Here's what I found, in the aspx page of the other project

onclick='document.forms[0].btnTest.click();'

It looks like this was clicking a button, on the click event of another
control.

So I tried this: (image button ibPkgB is an image button, that, when you
click it, does what I want to happen on a mouse over...)

iBut.Attributes.Add("onMouseOver", "document.forms[0].ibPkgB.click();")

Gave me an error, so I tried:
iBut.Attributes.Add("onMouseOver", "document.ibPkgB.click();")

I checked, and ibPkgB's "ID" and "ClientID" properties are both "ibPkgB" so
it didn't seem worthwhile adding that to the script.

So that's all I've tried so far...

---Selden

"Selden McCabe" <se*****@msn.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
Thanks, good suggestion!

Here's what I've tried, what worked and what didn't:

First, there is a panel on the page, "Panel1" if I set it's CssClass to
"vs1" it is visible. If I set it to "vs2" it is invisible. I've
confirmed this several times.

this worked:
sPic3 = "family/purchase/images/portrait_navs/" & sTitle &
"3.gif"
iBut.Attributes.Add("onMouseOver", "this.src='" & sPic3 & "'")

This gave me a script error: (tried with and without the return false):
script = "document.GetElementByID('panel1').className =
'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

This also gave me a script error:
script = "document.getElementById('" & Panel1.ClientID &
"').className = 'vs1'; "
iBut.Attributes.Add("onMouseOver", script)

As an aside, setting the panel visible/invisible is a fall back. What I
would REALLY want to do is set the text of a label to any one of 15
different values, depending on what button the mouse is rolling over.
Also I would want to set the image for an image control at the same time.
But if I can't do that, then I thought I would pre-set up 15 different
panels with the values already filled in, and just make one visible at the
rollover.

---Selden


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id
(the name of the textbox appended to the user control). This might be
what's happening.

Or it could simply be that it's getElementById instead of
GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className
= 'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
>I have a form with a bunch of image buttons. When the user moves the
>mouse over a button, I want to do two things: 1. change the
>Imagebutton's picture, and 2. make another control visible.
>
> I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
> 'somepicture.jpg')
> and that works fine.
>
> I've tried some java script to change the other control's visible
> property by changing is className, but that doesn't seem to work
>
> script = "document.GetElementByID('panel1').className = 'vs1';return
> false;"
> iBut.Attributes.Add("onMouseOver", script)
>
> but that gives me a script error on the page when I mouseover the
> image button. (I've tried it with and without the return false)
>
> So how do I change the visibility property of a control in javascript,
> and then, how do I combine two steps into one onMouseOver?
>
> Thanks!
> ---Selden <--- java newbie!
>



Nov 19 '05 #7

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

Similar topics

1
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
1
by: Anushya | last post by:
Hi All Is it possible to set the mailitem Visible/Invisible by setting something like flag or any other way? Now developing in .NET. Anushya
4
by: Gibs | last post by:
Hi, How can i make a label visible/invisible? I am able to do it for text box by using document.form1.TextBox1.style.visibility="hidden"; But when i am giving the same for the label, i am getting...
8
by: Roy | last post by:
What is the best way to approach this problem? I have a datagrid with an imagebutton. When one clicks the imagebutton it triggers an onClick sub which makes column 9 (a user control) visible or...
6
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with...
0
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
1
by: SP | last post by:
Hello there, I have a DataList create as below. <asp:DataList ID="dl_Immunpsuppressive_Main" Runat="server" Width="100%"> <ItemTemplate> <table id="Immunpsuppressive_Main" width="100%"...
3
by: Joe | last post by:
I'm connecting to an Oracle database and running a query which returns data. The query can be fairly long - 2-3 minutes. I have a label set up on the form which is invisible to begin with. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.