Forecolor Change

G

Guest

I have an image placed on an aspx page.

<img id="xyz" onMouseOver="abc()" src="c:\temp\ijk.jpg"> My Text to Display

How can I change the forecolor of the text 'My Text to display' in function
abc()?

Either in java or c#
 
D

darrel

How can I change the forecolor of the text 'My Text to display' in function
abc()?

Either in java or c#

You could wrap the text in a wrapper SPAN and then change the color via the
CSS or Javascript.

Or you could hard-code the color in via a LABEL control or LITERAL control
and change it from the codebehind.

-Darrel
 
G

Guest

I tried a span. But no luck yet. Could you post a sample please?

I don't know how to do the label though.
 
J

Joel Palmer

Hi,

Here is some help...

<asp:Label id="Label1" runat="server">My Text to display</asp:Label>


public void abc()
{
Label1.forecolor = yourcolor; //or "blue"
}

BUT, of course you can't call a c# method directly from onmouseover of
image. So, the span solution is your best bet. Same idea as above.

<script>

function abc()
{
var mycolor ="green";
elspano.style.color = mycolor;
}
</script>
</head>
<body>

<IMG id="xyz" src="yourimage.gif" onMouseover="abc()"><SPAN id="elspano">my
text to display</SPAN>

</body>

Take care,
Joel
 
G

Guest

Excellent. It works.

However, how can I change the backcolor? What is the syntax for changing the
background color?
elspano.style.color = mycolor;???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top