我必须通过与 Image 一起显示键。但在我的示例中,我只能显示图像。如何使用包含密钥的文本框显示图像
控制器:
namespace SVGImageUpload.Controllers
{
public class TestController : Controller
{
Dictionary<string, string> _imgDict = null;//Dictionary datatype
public TestController()
{
_imgDict = new Dictionary<string, string>();
_imgDict.Add("Image1", "../../Images/wi0096-48.gif");
_imgDict.Add("Image2", "../../Images/down.png");
_imgDict.Add("Image3", "../../Images/wi0054-48.gif");
}
[HttpPost]
public ActionResult MapIcon(IEnumerable<string> image)
{
Hidden hid = new Hidden();
// hid.hiddevalue = image1;
// string val = "";
foreach (var item in image)
{
var keyValPair = item.Split('_');
var key = keyValPair[0];
var pair = keyValPair[1];
var imgPath = _imgDict[pair];
string val = imgPath;
urls.Add(val);
ViewData["list"] = urls; ;
}
return View("Custumize");
}
public ActionResult Custumize()
{
return View();
}
}
}
剃刀视图:
@using (Html.BeginForm())
{
foreach (var m in (List<string>)ViewData["list"])
{
<ul>
<li>
<img src="@m" alt=""/>
</li>
</ul>
}
}
我试过但没有成功。怎么做?