Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to
I want to have RadioButton with Image instead of text, that clicking on image the check-box will be selected
In the thread it is shown Radio button (without any text) and image on it's side.(but not inside radio-button)
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="A1"
/><asp:image runat="server" id="Image2" /><br />
Radiobuttonlist Image Setting thread  suggests to use code
RadioButtonList1.Items.Add(New ListItem("<img src=""" + s + """/>", s))

It will be useful (TODO) to create derided from RadioButton control- RadioButtonWithImage, similar to what I've done previously : ASP.NET custom control HyperLinkWithImage and ASP.NET custom control CheckBoxWithImage
There is somehow related post and thread about creating custom control based on RadioButtonList.
Posted on Friday, May 16, 2008 4:21 PM ASP.NET | Back to top

Comments on this post: RadioButton with Image instead of text

# re: RadioButton with Image instead of text
Requesting Gravatar...
I ran into a need for this recently, but from within a composite control in a class library. Unfortunately, the above approach fails in my context due to the relative addressing of the image to the "calling" project. I eventually got around it by using code like the following...

System.Web.UI.HtmlControls.HtmlImage visaImage = new System.Web.UI.HtmlControls.HtmlImage();
visaImage.Src = Page.ClientScript.GetWebResourceUrl(this.GetType(), pathToEmbeddedImageVisa);
visaImage.Alt = "Visa";
visaImage.Border = 0

Getting this to work with IE was another story [involving Javascript].

Left by Jason Vogel on Jun 02, 2008 5:55 AM

# re: RadioButton with Image instead of text
Requesting Gravatar...
This is actually really quite easy:

<asp:RadioButton ID="btnBlack" runat="server" Checked="True" GroupName="ink" Text='&lt;img src=&#39;/Images/blackink.gif&#39;&gt;' />

Left by Ryan on Mar 26, 2009 6:15 AM

Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: