在HomeController的方法不叫 [英] Method in HomeController not called
本文介绍了在HomeController的方法不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试从我的视图页面调用一个方法,但它不叫。
家庭控制器的我的样本code是
I try to call a method from my view page but it is not called. My sample code of Home Controller is
public ActionResult Sample(Guid id)
{
List<Images> imgList = ImagesManager.GetAlllImages();
var bindlist = (from i in imgList where id == i.ImageId select i).ToList();
return RedirectToAction("Index",bindlist);
}
和从那里我试图把它叫做我的.cshtml网页(视图)code是
And my .cshtml page(view ) code from where I try to call it is
<div class="product">
<a href="Sample/?Id=@item.ImageId" class="info">
<span class="holder">
<img src="@item.ImagePath" alt="">
<span class="dd" >@item.ImageName</span>
<span class="author">by John Smith</span>
为什么不叫样本的方法。
Why the "Sample" method not called.
错误是未找到资源
推荐答案
我觉得这是你在找什么。
I think this is what you are looking for
@Html.ActionLink(
"text for your link",
"Sample", // action method
"Home", // controller
new { id = item.ImageId }, // your variable you want to pass
null)
这篇关于在HomeController的方法不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文