【问题标题】:MVC Form in MasterPage not workingMasterPage 中的 MVC 表单不起作用
【发布时间】:2010-10-26 02:05:02
【问题描述】:

好的,这有点令人困惑和沮丧。 这是我的母版页中的内容:

<%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>

问题是为什么 action 是空的,而我在声明 HTML.Helper 时提到了 action 和 controllername ???? 因此,由于显而易见的原因,seach 无法正常工作。

请帮忙。谢谢。

【问题讨论】:

    标签: asp.net-mvc-2 master-pages


    【解决方案1】:

    我认为您的问题是您使用的是“SearchController”,但您只需要使用“Search”,因为 MVC 框架会添加“控制器”一词。

    另外,这并不重要,但您缺少一个结束输入标签

    【讨论】:

    • 非常非常愚蠢的错误。我不敢相信我在后面浪费了 4 个小时。谢谢老兄。
    猜你喜欢
    • 2023-03-07
    • 1970-01-01
    • 2014-02-24
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多