0

<a>在并排标签中有 texbox 和按钮(标签)<li>

<li>
    @Html.TextBox( "keyword", "", new { @placeholder = "Search", @class = "inputclass" } )
</li>
<li>
  <a href="@Url.Action( "Index", "Home", new { keyword = ?????? } )" >
     <img src="@Url.Content( "~/Content/images/search.png" )"  width = "83px"  height="29px"  />
     <p class="searchClass">Search</p>
  </a>
</li>

索引操作具有关键字参数。何将文本框中的关键字发送到索引操作?

4

2 回答 2

2
<li>
    @Html.TextBox( "keyword", "", new { @placeholder = "Search", @class = "inputclass" } )
</li>
<li>
  <a href="javascript:send();" >
     <img src="@Url.Content( "~/Content/images/search.png" )"  width = "83px"  height="29px"  />
     <p class="searchClass">Search</p>
  </a>
</li>

<script type="text/javascript">
function send(){
    var textboxValue = $('input[name=keyword]').val();
    window.location.href = "/Home/Index?keyword=" + textboxValue;
}
</script>
于 2012-08-23T13:05:57.880 回答
1

将文本框放在表单中,并让链接将表单提交给您感兴趣的操作方法。查看@html.BeginForm 以获取指针。

于 2012-08-23T12:50:11.823 回答