PC Review


Reply
Thread Tools Rate Thread

Apply stylesheet to Hyperlink server control

 
 
Redhairs
Guest
Posts: n/a
 
      10th Jan 2008
When I set up a image link with Hyperlink server control as below
<asp:HyperLink ID="thelink" runat=server Text="thelink"
NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
style="border-width:0px;"></a>

How to remove the built-in style and apply style sheet to the <img> tag?


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      10th Jan 2008
Make your own style class in a stylesheet and assign it to the CssClass
property. Or make a rule for a or for img. You can make it apply to that
link only. There are many thinks you can make with css.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Redhairs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> When I set up a image link with Hyperlink server control as below
> <asp:HyperLink ID="thelink" runat=server Text="thelink"
> NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
> the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
> style="border-width:0px;"></a>
>
> How to remove the built-in style and apply style sheet to the <img> tag?
>
>



 
Reply With Quote
 
Redhairs
Guest
Posts: n/a
 
      10th Jan 2008
I have tried both way but they don't work.
If I set the CssClass of the HyperLink control, the class property will be
added to the <A> tag instead of the <Img> tag.
I also create css rule for img but the default style(border-width:0px" will
override the rule.

"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Make your own style class in a stylesheet and assign it to the CssClass
> property. Or make a rule for a or for img. You can make it apply to that
> link only. There are many thinks you can make with css.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
>
>
> "Redhairs" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> When I set up a image link with Hyperlink server control as below
>> <asp:HyperLink ID="thelink" runat=server Text="thelink"
>> NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
>> the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
>> style="border-width:0px;"></a>
>>
>> How to remove the built-in style and apply style sheet to the <img> tag?
>>
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      10th Jan 2008
Make your css class in this way:

border-width:2px!important;

And you don't have to use Hyperlink if it doesn't suit you. Just use html
markup with runat=server.


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Redhairs" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
>I have tried both way but they don't work.
> If I set the CssClass of the HyperLink control, the class property will be
> added to the <A> tag instead of the <Img> tag.
> I also create css rule for img but the default style(border-width:0px"
> will override the rule.
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> Make your own style class in a stylesheet and assign it to the CssClass
>> property. Or make a rule for a or for img. You can make it apply to that
>> link only. There are many thinks you can make with css.
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP [ASP.NET]
>> http://msmvps.com/blogs/egoldin
>>
>>
>> "Redhairs" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> When I set up a image link with Hyperlink server control as below
>>> <asp:HyperLink ID="thelink" runat=server Text="thelink"
>>> NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
>>> the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
>>> style="border-width:0px;"></a>
>>>
>>> How to remove the built-in style and apply style sheet to the <img> tag?
>>>
>>>

>>
>>

>
>


 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      10th Jan 2008
On 10 Січ, 03:24, "Redhairs" <redh...@u.s.a> wrote:
> When I set up a image link with Hyperlink server control as below
> <asp:HyperLink ID="thelink" runat=server Text="thelink"
> NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
> the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
> style="border-width:0px;"></a>
>


Another variant is using nested IMG element instead of setting
ImageUrl property.
Something like this:
<asp:HyperLink ID="thelink" runat=server NavigateUrl="#toWhere"><img
src="theLinkIMage.gif"/></asp:HyperLink>

Regards,
Mykola
http://marss.co.ua

 
Reply With Quote
 
Redhairs
Guest
Posts: n/a
 
      11th Jan 2008
I need to use Image server control in order set the image programmatically
"marss" <(E-Mail Removed)> wrote in message
news:d383fd6d-c63d-43b7-9c6a-(E-Mail Removed)...
On 10 ???, 03:24, "Redhairs" <redh...@u.s.a> wrote:
> When I set up a image link with Hyperlink server control as below
> <asp:HyperLink ID="thelink" runat=server Text="thelink"
> NavigateUrl="#toWhere" ImageUrl="theLinkIMage.gif" />
> the html output will be <a href="#toWhere"><Img src="theLinkImage.gif"
> style="border-width:0px;"></a>
>


Another variant is using nested IMG element instead of setting
ImageUrl property.
Something like this:
<asp:HyperLink ID="thelink" runat=server NavigateUrl="#toWhere"><img
src="theLinkIMage.gif"/></asp:HyperLink>

Regards,
Mykola
http://marss.co.ua


 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      11th Jan 2008
On 11 Січ, 21:16, "Redhairs" <redh...@u.s.a> wrote:
> I need to use Image server control in order set the image programmatically


Just add runat="server" attribute and id.

<asp:HyperLink ID="thelink" runat=server NavigateUrl="#toWhere"><img
id="theLinkIMage" runat="server"/></asp:HyperLink>

Server-side code: theLinkIMage.Src = "theLinkIMage.gif"

Or use Image web control:
<asp:HyperLink ID="thelink" runat=server
NavigateUrl="#toWhere"><asp:Image id="theLinkIMage" runat=server
ImageUrl="theLinkIMage.gif"></asp:Image></asp:HyperLink>

Regards,
Mykola
http://marss.co.ua
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: I can't get the hyperlink character style to apply to an actual hyperlink. Suzanne S. Barnhill Microsoft Word New Users 1 9th Sep 2011 03:07 PM
Can the validation control apply to server controls other than TextBox? chenhong Microsoft ASP .NET 3 4th Sep 2007 08:06 AM
server control menu or hyperlink? newcomer2k@yahoo.com Microsoft ASP .NET 1 2nd Feb 2007 11:17 PM
server control for asp.net that has server events ... but only displays as a hyperlink.. or text lnk Darren Clark Microsoft Dot NET 1 29th Feb 2004 09:43 AM
How to apply a stylesheet to new pages. Frank Rizzo Microsoft ASP .NET 3 16th Jan 2004 10:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:50 PM.