locked
A Problem with ASP.NET HyperLink NavigateUrl RRS feed

  • Question

  • Hello :

    I Use ImageUrl Property(HyperLink Control) for inser a picture in site (My picture don't have any border , any) , now when I run the program I DON'T HAVE ANY PROBLEM BUT , WHEN I USE NavigateUrl for this control(Hyperlink) and run the program , My Picture has a Border !!! ( But My Original Don't have any border , any ) . ON THE OTHER HAND  I set the Borderstyle and BorderWith Properties for resolve the problem but It dosn't work . Please Help Me.

    Thursday, September 1, 2011 12:50 PM

Answers

  • I whacked the following into a new web site in default.aspx

                <style type="text/css"> a img, a:link img, a:visited img, a:hover img, a:active img { border:0; }</style>
                <asp:HyperLink  ImageUrl="/images/Desert.jpg" NavigateUrl="~/About.aspx" runat="server"></asp:HyperLink>


    No border.

    I also added a folder called images and dragged the desert.jpg out of example pictures on my win 7 machine. 

     

    You probably don't want borders round any link images so you could stick that in a central css file.

    Before you do.

    Read up on how css styling works.

    There's a shed load of html orientated resources out there on  the web or books.

    • Marked as answer by SS-Programmer Sunday, September 4, 2011 6:28 AM
    Friday, September 2, 2011 6:42 PM
  • Happy to help.

    If you drop back in, please mark my reply as answer so people can see there's an answer in the thread if they search in future.

    And I get the points.

     

    • Marked as answer by SS-Programmer Sunday, September 4, 2011 6:28 AM
    Saturday, September 3, 2011 10:31 AM

All replies

  • Any image will by default have a border.

    You need a bit of css to style your anchor images so they have border:0

    If you're OK with all anchors having no border in your page you could use some inline css.

    If you're thinking inline style then google it for more info.

    You want something like

    <style type="text/css"> a img, a:link img, a:visited img, a:hover img, a:active img { border:0; }</style>
    

     

    Your image is an anchor tag and this applies to all anchor tags in your page.

    You could alternatively stick a style on your asp.net tag.  I'll leave you to find exactly how to do that as it's pretty trivial ( see them squiggly brackets ).

    I recommend reading up on styling and css if you're doing any asp.net development.

    You can get away with pretty much zero javascript if you do webforms but you will need to understand styling.
    ( Note this is aircode and not cut and paste guaranteed ).
    • Marked as answer by SS-Programmer Thursday, September 1, 2011 2:38 PM
    • Unmarked as answer by SS-Programmer Thursday, September 1, 2011 3:20 PM
    Thursday, September 1, 2011 1:09 PM
  • Thank You Andy , but

    I use WebSite Design Stage with Css and I Know A little about it , I Use Css class with no <Style> but with Apply and Atach Style , is it different ? and I use it but ,No it doesn't work.

    Using Css :

    .PicBorder
    {
      border:0; 
    }
    

    and PicBorder is Belong to HeaderDownCss Style That I Make it as a file in Css Folder in My Project . is it wrong or not ? then I Connect this style to Hyperlink .

    why when i use imageurl property and put the pictutre in site everything is ok? but when I use NavigateUrl this problem appeares!! why?

    thank you.


    Thank You
    Thursday, September 1, 2011 2:17 PM
  • Andy , I'm beginner in this forum and i'm sorry for marked and unmarked answer.


    Thank You
    Friday, September 2, 2011 7:12 AM
  • I whacked the following into a new web site in default.aspx

                <style type="text/css"> a img, a:link img, a:visited img, a:hover img, a:active img { border:0; }</style>
                <asp:HyperLink  ImageUrl="/images/Desert.jpg" NavigateUrl="~/About.aspx" runat="server"></asp:HyperLink>


    No border.

    I also added a folder called images and dragged the desert.jpg out of example pictures on my win 7 machine. 

     

    You probably don't want borders round any link images so you could stick that in a central css file.

    Before you do.

    Read up on how css styling works.

    There's a shed load of html orientated resources out there on  the web or books.

    • Marked as answer by SS-Programmer Sunday, September 4, 2011 6:28 AM
    Friday, September 2, 2011 6:42 PM
  • Thank You For Your Help Andy, Thank You.
    Thank You
    Saturday, September 3, 2011 2:24 AM
  • Happy to help.

    If you drop back in, please mark my reply as answer so people can see there's an answer in the thread if they search in future.

    And I get the points.

     

    • Marked as answer by SS-Programmer Sunday, September 4, 2011 6:28 AM
    Saturday, September 3, 2011 10:31 AM