在我的一个 ASP.Net 项目中,我使用了 selected-image ( https://github.com/djgrant/chosen-image ) 将图像添加到下拉列表。
我也添加了选择的库。一切正常。如果我在文档加载功能中使用以下代码,它将创建选择的列表视图。
$(document).ready(function () {
$(".chosen-select").chosen({
disable_search_threshold: 10
});
}
然后我想将图像添加到列表视图。所以我添加了 selected-image js 文件和 css 文件并将上面的代码更改如下。
$(document).ready(function () {
$(".chosen-select").chosenImage({
disable_search_threshold: 10
});
}
在后端,我将图像绑定到列表视图。
protected void Bind_BuyerImages() {
if (cmbBuyer != null)
{
foreach (ListItem li in cmbBuyer.Items)
{
li.Attributes["data-img-src"] = "../Buyers/" + li.Value;
}
}
}
在列表视图中显示所有图像,但页面不断刷新。我怎样才能防止这种情况?