2017-03-07 58 views
-1


我有我的_layout页面的代码,因为在导航栏搜索栏:广东话后,以其他形式

@using (Html.BeginForm("Search", "Home", FormMethod.Post)) 
{ 
    <div class="col-sm-3 col-md-3 pull-right"> 
     <div class="navbar-text">Zoeken</div> 
     <input type="text" id="SearchText" name="SearchText" class="form-control" /> 
     <button id="search" class="btn btn-default" type="submit" value="Search"> 
      <i class="glyphicon glyphicon-search"></i> 
     </button> 
    </div> 
} 

,这在我的控制器

[HttpPost] 
    public ActionResult Search(string SearchText) 
    { 
     ProductDbContext pdb = new ProductDbContext(); 
     return RedirectToAction("Search", pdb.Search(SearchText)); 
    } 

    public ActionResult Search(List<Product> producten) 
    { 
     return View(producten); 
    } 

但是代码总是进入此行动结果提交:

public ActionResult Index() 
{ 
    return View(); 
} 

请有人向我解释我在做什么错在提交。
我无法以某种方式解决这个问题,即使这对我来说看起来很简单。

+0

你有嵌套表单吗? –

回答

1

你可以改变按钮输入类型,并试试看。其他一切都很好。

+0

按钮的输入类型只能重置|提交|按钮。编辑:没有工作 –

+1

在你的情况,用这个替换按钮标签,你应该没问题。该按钮不会自己提交,这就是为什么你正在打索引方法本身。 –

+0

这是错误的,并没有什么区别 - ''和'