Hi @Sun ,
By default, when using the <select>
tag helper, we can't use it to display the select option with image icon.
To display the select option with image icon, you can try to use some JQuery Image DropDownList plugin (search "jquery image dropdown" online, there should have lots of sample or tutorials), or re-create the Dropdownlist and its select container based on the select tag, refer to the following code:
The ImageOption class:
public class ImageOption
{
public string Value { get; set; }
public string Text { get; set; }
public string ImageIcon { get; set; }
}
Then, in the view, use the following code to display the select options, and then add the CSS style and JS scripts:
view the source code: 216802-sourcecode.txt
[Note] Since I'm using the layout page, the JQuery and Boostrap reference has been added to the layout page, if you are not using the layout page, you have to add the JQuery and Bootstrap reference.
After that, the output is like this:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion