RadioButtonList with image throwing XXS error on postback

孤人 提交于 2020-01-06 20:08:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!