Changing and image to a text field.

Discussion in 'ASP .Net' started by JB, Feb 27, 2007.

  1. JB

    JB Guest

    I have a set of links that are currently images that when the person rolls
    over them, they change color. Essentially the image is a box where the
    background is brown and the text is blue. When the person rolls over it,
    they want it blue background with brown text. As I said we currently do
    images but that is annoying.

    Is there an easy way ( or at least relatively easy ) way to do this just
    using text and javascript to change the colors?

    TIA - Jeff.
     
    JB, Feb 27, 2007
    #1
    1. Advertising

  2. Howdy,

    Yes, it's quite simple. Here is a rough example that should give you an idea
    where to go:

    <style type="text/css">
    ..MouseOut
    {
    border: solid 1px black;
    background-color: orange;
    color: blue;
    }
    ..MouseOver
    {
    border: solid 1px red;
    background-color: brown;
    color: white;
    }
    </style>
    <asp:HyperLink runat="server" ID="myLink" CssClass="MouseOut"
    onmouseover="ChangeApperance(this, true)"
    onmouseout="ChangeApperance(this, false)" Text="Click me!" NavigateUrl="#" />

    <script type="text/javascript">

    function ChangeApperance(anchor, isMouseOver)
    {
    if (anchor)
    {
    anchor.className = isMouseOver ? 'MouseOver' : 'MouseOut';
    }
    }

    </script>

    Please note your requirement is a perfect subject to build a web server
    control inheriting from hyperlink.

    --
    Milosz


    "JB" wrote:

    > I have a set of links that are currently images that when the person rolls
    > over them, they change color. Essentially the image is a box where the
    > background is brown and the text is blue. When the person rolls over it,
    > they want it blue background with brown text. As I said we currently do
    > images but that is annoying.
    >
    > Is there an easy way ( or at least relatively easy ) way to do this just
    > using text and javascript to change the colors?
    >
    > TIA - Jeff.
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 27, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J Sahoo
    Replies:
    3
    Views:
    5,352
    naikpalak
    Apr 30, 2009
  2. Carlos CR

    Dinamically changing the Text Field of a LinkButton in a DataGrid

    Carlos CR, May 3, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    221
    Carlos CR
    May 4, 2004
  3. ehm
    Replies:
    2
    Views:
    222
  4. Sound
    Replies:
    2
    Views:
    501
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    499
Loading...

Share This Page