Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 22, 2013 05:05 PM by ivoinc
Member
130 Points
28 Posts
May 26, 2006 08:57 PM|LINK
Contributor
3515 Points
694 Posts
May 28, 2006 12:48 PM|LINK
HyperLink control do has both properties:
<asp:HyperLink Runat="server" ID="hyperLinkTemp" Height="100px" Width="100px"></asp:HyperLink>
Let me know if I am missing something here.
15 Points
3 Posts
May 30, 2006 05:26 PM|LINK
All-Star
82577 Points
15430 Posts
MVP
May 30, 2006 05:57 PM|LINK
You can't. Use an ImageButton instead.
NC...
7 Points
2 Posts
Jun 02, 2006 03:49 AM|LINK
Jun 02, 2006 11:37 AM|LINK
Wouldn't it be far easier to just use an ImageButton, which will do the same thing, instead of having to dynamically add controls, bringing in to play the problems and complexities that they bring to the page?
106 Points
98 Posts
Jun 19, 2008 10:22 PM|LINK
One problem with using an ImageButton is that there is no Target property. In case anyone comes across this thread in the future, here is a solution:
<asp:HyperLink runat="server" ID="hlThumbnail" NavigateUrl='<%# Eval("Url") %>' Target="_blank" Style="height: 66px;"> <asp:Image runat="server" ID="imgThumbnail" Height="66px" ImageUrl='<%# Eval("Thumbnail") %>' /> </asp:HyperLink>
Jun 20, 2008 11:05 AM|LINK
This post is over 2 years old.
191 Points
145 Posts
Jul 28, 2009 02:46 AM|LINK
Unbelievable.
No elegant solution yet.
Can I access the underlying img that will be generated by the HyperLink?
So I can create an extension method
public static void FixImage(this HyperLink hl) { HtmlImage img = hl.<undelying image>; img.Height = 234; img.Width = 432; }
Jul 28, 2009 11:24 AM|LINK
weitzhandler Unbelievable. No elegant solution yet. Can I access the underlying img that will be generated by the HyperLink? So I can create an extension method <div class=dp-highlighter> <div class=bar> <div class=tools>view plaincopy to clipboardprint?</div></div> public static void FixImage(this HyperLink hl) { HtmlImage img = hl.<undelying image>; img.Height = 234; img.Width = 432; } </div>public static void FixImage(this HyperLink hl) { HtmlImage img = hl.<undelying image>; img.Height = 234; img.Width = 432; }
I doubt if there is a solution since this: <asp:HyperLink ID="HyperLink1" ImageUrl="~/Images/SomeImage.gif" runat="server"></asp:HyperLink>
renders as: <a id="HyperLink1"><img src="Images/SomeImage.gif" style="border-width:0px;" /></a>
Note there is no ID property on the img element
You could try this: <a id="HyperLink1" runat="server"><img id="HyperLinkImage" src="Images/SomeImage.gif" style="border-width:0px;" runat="server" /></a>
and in the CodeBehind: HyperLinkImage.Height = 234; HyperLinkImage.Width = 432;
johnqh
Member
130 Points
28 Posts
How to control the image size of a Hyperlink?
May 26, 2006 08:57 PM|LINK
firoz.ansari
Contributor
3515 Points
694 Posts
Re: How to control the image size of a Hyperlink?
May 28, 2006 12:48 PM|LINK
HyperLink control do has both properties:
<asp:HyperLink Runat="server" ID="hyperLinkTemp" Height="100px" Width="100px"></asp:HyperLink>
Let me know if I am missing something here.
kguy
Member
15 Points
3 Posts
Re: How to control the image size of a Hyperlink?
May 30, 2006 05:26 PM|LINK
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: How to control the image size of a Hyperlink?
May 30, 2006 05:57 PM|LINK
You can't. Use an ImageButton instead.
NC...
Dr_Software
Member
7 Points
2 Posts
Re: How to control the image size of a Hyperlink?
Jun 02, 2006 03:49 AM|LINK
HyperLink hl = new HyperLink();
hl.NavigateUrl = .....
HtmlImage img = new HtmlImage();
img.Src = .....
img.Height = 64;
hl.Controls.Add(img);
DC
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: How to control the image size of a Hyperlink?
Jun 02, 2006 11:37 AM|LINK
Wouldn't it be far easier to just use an ImageButton, which will do the same thing, instead of having to dynamically add controls, bringing in to play the problems and complexities that they bring to the page?
NC...
TheSneak
Member
106 Points
98 Posts
Re: How to control the image size of a Hyperlink?
Jun 19, 2008 10:22 PM|LINK
One problem with using an ImageButton is that there is no Target property. In case anyone comes across this thread in the future, here is a solution:
<asp:HyperLink runat="server" ID="hlThumbnail" NavigateUrl='<%# Eval("Url") %>' Target="_blank" Style="height: 66px;"> <asp:Image runat="server" ID="imgThumbnail" Height="66px" ImageUrl='<%# Eval("Thumbnail") %>' /> </asp:HyperLink>NC01
All-Star
82577 Points
15430 Posts
MVP
Re: How to control the image size of a Hyperlink?
Jun 20, 2008 11:05 AM|LINK
This post is over 2 years old.
NC...
Weitzhandler
Member
191 Points
145 Posts
Re: How to control the image size of a Hyperlink?
Jul 28, 2009 02:46 AM|LINK
Unbelievable.
No elegant solution yet.
Can I access the underlying img that will be generated by the HyperLink?
So I can create an extension method
public static void FixImage(this HyperLink hl) { HtmlImage img = hl.<undelying image>; img.Height = 234; img.Width = 432; }NC01
All-Star
82577 Points
15430 Posts
MVP
Re: How to control the image size of a Hyperlink?
Jul 28, 2009 11:24 AM|LINK
I doubt if there is a solution since this:
<asp:HyperLink ID="HyperLink1" ImageUrl="~/Images/SomeImage.gif" runat="server"></asp:HyperLink>
renders as:
<a id="HyperLink1"><img src="Images/SomeImage.gif" style="border-width:0px;" /></a>
Note there is no ID property on the img element
You could try this:
<a id="HyperLink1" runat="server"><img id="HyperLinkImage" src="Images/SomeImage.gif" style="border-width:0px;" runat="server" /></a>
and in the CodeBehind:
HyperLinkImage.Height = 234;
HyperLinkImage.Width = 432;
NC...