Home All Groups Group Topic Archive Search About

Customizing ASP.NEt Hyperlink Control

Author
13 Apr 2005 7:34 AM
Saket Mundra
I am using the ASP.NET Hyperlink Control in my web forms. I have following
queries regarding same:
1) How do I change the default Cursor symbol for hyperlink control?
2) How do i get rid of the underline that appears by default in the
hyperlink control?
3) Is is possible to change the color of hyperlink control on client side
events such as
   onmouseover ? If yes, How?

Pls Help. Any Help is appreciated.
--
Thank You.

Saket Mundra

Author
13 Apr 2005 12:36 PM
Ken Cox [Microsoft MVP]
Hi Saket,

There's lots you can do with styles and inline code to accomplish what
you're after. I've put together some sample code to give you the idea.

  <style>
  .noline {text-decoration: underline overline blink none;color:blue}
  </style>
    </head>
    <body >
        <form id="Form1" method="post" runat="server">
            <asp:hyperlink id="HyperLink1" runat="server"
navigateurl="http://authors.aspalliance.com/kenc/">Click Me!</asp:hyperlink>
        </form>

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        HyperLink1.Attributes.Add _
         ("onmouseover", _
          "this.style.cursor='wait';this.style.color='green'")
        HyperLink1.Attributes.Add _
        ("onmouseout", _
        "this.style.cursor='hand';this.style.color='purple'")
        HyperLink1.CssClass = "noline"
    End Sub

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto


Show quoteHide quote
"Saket Mundra" <SaketMun***@discussions.microsoft.com> wrote in message
news:7E944826-918B-412B-AA9F-B474D93F2DAA@microsoft.com...
>I am using the ASP.NET Hyperlink Control in my web forms. I have following
> queries regarding same:
> 1) How do I change the default Cursor symbol for hyperlink control?
> 2) How do i get rid of the underline that appears by default in the
> hyperlink control?
> 3) Is is possible to change the color of hyperlink control on client side
> events such as
>   onmouseover ? If yes, How?
>
> Pls Help. Any Help is appreciated.
> --
> Thank You.
>
> Saket Mundra
Author
13 Apr 2005 7:18 PM
Saket Mundra
Hi all,

Thanx for your help & time. 2 of my original queries are sorted.

I have not been able to get rid of the underline from the hypelink control.
I am using Visual Studio Enterprise Architect 2003. The targetSchema for my
web form is Internet Explorer 5.0. So whenever i try to insert the style tags
in the HEAD tag of the document I get an error stating that the active schema
doesn't supports the tag.

However in the default Stylesheet created by Visual Studio I found a class
with the name A: link and i changed the text-decoration element to none. But
it still doesn't works out.
Also pls tell me how to reference a particular class from this default
stylesheet created by Visual Studio for a control.

Pls help.

Thanx once Again.

Saket
Author
13 Apr 2005 11:08 PM
Mythran
Show quote Hide quote
"Saket Mundra" <SaketMun***@discussions.microsoft.com> wrote in message
news:97C3163D-3E63-4CD3-B10A-DAB4F8ABF5C3@microsoft.com...
> Hi all,
>
> Thanx for your help & time. 2 of my original queries are sorted.
>
> I have not been able to get rid of the underline from the hypelink
> control.
> I am using Visual Studio Enterprise Architect 2003. The targetSchema for
> my
> web form is Internet Explorer 5.0. So whenever i try to insert the style
> tags
> in the HEAD tag of the document I get an error stating that the active
> schema
> doesn't supports the tag.
>
> However in the default Stylesheet created by Visual Studio I found a class
> with the name A: link and i changed the text-decoration element to none.
> But
> it still doesn't works out.
> Also pls tell me how to reference a particular class from this default
> stylesheet created by Visual Studio for a control.
>
> Pls help.
>
> Thanx once Again.
>
> Saket
>
>

Read my other post if you haven't already :)   Anywho, to make the
stylesheet active for the document you are working with, open the solution
explorer window and drag-n-drop the stylesheet onto the web form (in the web
form window).

This will add something like the following:

<link rel=stylesheet type=text/stylesheet href=stylesheet.css>

Try it out :)

Mythran
Author
14 Apr 2005 7:45 AM
Saket Mundra
Thank You for helping me out. This time it worked.

Show quoteHide quote
"Mythran" wrote:

>
> "Saket Mundra" <SaketMun***@discussions.microsoft.com> wrote in message
> news:97C3163D-3E63-4CD3-B10A-DAB4F8ABF5C3@microsoft.com...
> > Hi all,
> >
> > Thanx for your help & time. 2 of my original queries are sorted.
> >
> > I have not been able to get rid of the underline from the hypelink
> > control.
> > I am using Visual Studio Enterprise Architect 2003. The targetSchema for
> > my
> > web form is Internet Explorer 5.0. So whenever i try to insert the style
> > tags
> > in the HEAD tag of the document I get an error stating that the active
> > schema
> > doesn't supports the tag.
> >
> > However in the default Stylesheet created by Visual Studio I found a class
> > with the name A: link and i changed the text-decoration element to none.
> > But
> > it still doesn't works out.
> > Also pls tell me how to reference a particular class from this default
> > stylesheet created by Visual Studio for a control.
> >
> > Pls help.
> >
> > Thanx once Again.
> >
> > Saket
> >
> >
>
> Read my other post if you haven't already :)   Anywho, to make the
> stylesheet active for the document you are working with, open the solution
> explorer window and drag-n-drop the stylesheet onto the web form (in the web
> form window).
>
> This will add something like the following:
>
> <link rel=stylesheet type=text/stylesheet href=stylesheet.css>
>
> Try it out :)
>
> Mythran
>
>
Author
13 Apr 2005 12:37 PM
Ken Cox [Microsoft MVP]
BTW, Here's a great resource for style information:

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_style.asp?frame=true


Show quoteHide quote
"Saket Mundra" <SaketMun***@discussions.microsoft.com> wrote in message
news:7E944826-918B-412B-AA9F-B474D93F2DAA@microsoft.com...
>I am using the ASP.NET Hyperlink Control in my web forms. I have following
> queries regarding same:
> 1) How do I change the default Cursor symbol for hyperlink control?
> 2) How do i get rid of the underline that appears by default in the
> hyperlink control?
> 3) Is is possible to change the color of hyperlink control on client side
> events such as
>   onmouseover ? If yes, How?
>
> Pls Help. Any Help is appreciated.
> --
> Thank You.
>
> Saket Mundra
Author
13 Apr 2005 3:50 PM
Mythran
Show quote Hide quote
"Saket Mundra" <SaketMun***@discussions.microsoft.com> wrote in message
news:7E944826-918B-412B-AA9F-B474D93F2DAA@microsoft.com...
>I am using the ASP.NET Hyperlink Control in my web forms. I have following
> queries regarding same:
> 1) How do I change the default Cursor symbol for hyperlink control?
> 2) How do i get rid of the underline that appears by default in the
> hyperlink control?
> 3) Is is possible to change the color of hyperlink control on client side
> events such as
>   onmouseover ? If yes, How?
>
> Pls Help. Any Help is appreciated.
> --
> Thank You.
>
> Saket Mundra

Using stylesheet :)

<html>
    <head>
        <style>
            A:LINK, A:VISITED, A:ACTIVE {
                color : Green;
                text-decoration : none;
            }

            A:HOVER {
                cursor : crosshair;
                color  : Blue;
            }
        </style>
    </head>
    <body>
        <a href="http://www.google.com">www.google.com</a>
    </body>
</html>

Hope that helps :)