问题
I have managed to add an image to a radio button by the following code
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='ThemeImages/blue.png'>","fsd")));
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='ThemeImages/green.png'>")));
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='ThemeImages/red.png'>")));
works fine. However due to the html gives a cross side scripting alert. Anyway around this?
回答1:
you can try with :
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='{0}'>", "ThemeImages/blue.png") ,"fsd"));
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='{0}'>", "ThemeImages/green.png") ));
themeRadioButtonList.Items.Add(
new ListItem(String.Format("<img src='{0}'>", "ThemeImages/red.png") ));
来源:https://stackoverflow.com/questions/11645245/radiobuttonlist-with-image-throwing-xxs-error-on-postback