2010-10-26 31 views
0

好的,這有點令人困惑和沮喪。 下面是我在我的母版:MasterPage中的MVC窗體不工作

<%using (Html.BeginForm("Index", "SearchController", FormMethod.Post, new { @name = "dosearch" })) 
              {%> 
              <input type="text" name="ssearch" class="search"><a href="#" onclick="document.dosearch.submit();"><input id="Image1" type="image" runat="server" src="~/App_Themes/DefaultTheme/images/btn_search.gif" width="74" height="29" style="border:none" /></a> 
             <%} %> 

但相應生成的html是:

<form action="" method="post" name="dosearch"> 
              <input type="text" name="ticketSearch" class="search"><a href="#" onclick="document.dosearch.submit();"><input src="../App_Themes/DefaultTheme/images/btn_search.gif" name="ctl00$Image1" type="image" id="ctl00_Image1" width="74" height="29" style="border:none" /></a> 
             </form> 

的問題是爲什麼要採取行動,而空我提到動作和controllername聲明HTML.Helper什麼時候? ??? 作爲一個reasult,由於顯而易見的原因,搜索沒有工作。

請幫忙。謝謝。

回答

3

我認爲你的問題是你正在使用「SearchController」,但你只需要使用「搜索」,因爲MVC框架將添加單詞「控制器」。

此外,沒關係,但你錯過了一個輸入結束標籤

+0

非常非常愚蠢的錯誤。我無法相信我浪費了4小時。謝了哥們。 – 2010-10-26 05:10:49