我有并排<a>
标记的文本框和按钮(<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>
索引操作有关键字参数。何在文本框中将关键字发送到索引操作?
答案 0 :(得分: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>
答案 1 :(得分:1)
在表单中放置文本框并让链接将表单提交给您感兴趣的操作方法。查看@html.BeginForm以获取指针。