help in displaying image in Hyperlink control
-
Hi! i m developing web portal in C# asp.net web application. i want to display image in hyperlink control rather than text. i can do it by using hyperlink's property that is 'imageurl', but problem is that in hyperlink,image displays in actual size not in that size which i have given in hyperlink height and width property. can u plz tell me how i can restrict size of hyperlink upto my own requirment i mean i want to display all the images in hyperlink of size 100/100,even if image actual size is 500/500. just as i can do in image control.No matter how big image is but it always displays in that fixed size which i give to it. Thanx
-
Hi! i m developing web portal in C# asp.net web application. i want to display image in hyperlink control rather than text. i can do it by using hyperlink's property that is 'imageurl', but problem is that in hyperlink,image displays in actual size not in that size which i have given in hyperlink height and width property. can u plz tell me how i can restrict size of hyperlink upto my own requirment i mean i want to display all the images in hyperlink of size 100/100,even if image actual size is 500/500. just as i can do in image control.No matter how big image is but it always displays in that fixed size which i give to it. Thanx
Before I start, let me just say that if you want the images to display as 100x100, then it would be best and easier to simply resize the image and save it that way. However here are some options: 1) The easiest is to use HTML controls (an anchor "A" tag wrapped around an image "IMG" tag) instead of server controls. This is what is being rendered for you right now anyway when you are using the ImageUrl property of the Hyperlink control. The problem with it is that it doesn't set the Height and Width of the IMG element, it sets it for the A element. This is your best alternative. 2) If you are using the Hyperlink control because you want to use it for a postback event, then use the ImageButton control instead. The height and width properties of the ImageButton control will work in this case.