<div class="input-append">
<input type="text" id="txtSearch" name="txtSearch" class="autosuggest span10 classic-search" autofocus="true" tabindex="1" />
<button class="btn" type="button" id="SchButton" onserverclick="GetDistributorRegNo" runat="server">
<i class="icon-search"></i>
</button>
</div>
我想按回车键搜索内容。但我有onserverclick没有jquery的工作。
答案 0 :(得分:1)
您需要将输入和按钮包装在这样的表单标记中:
<form id="form1" method="post" runat="server">
<div class="input-append">
<input type="text" id="txtSearch" name="txtSearch" class="autosuggest span10 classic-search" autofocus="true" tabindex="1" />
<button class="btn" type="submit" id="SchButton" onserverclick="GetDistributorRegNo" runat="server">
<i class="icon-search"></i>
</button>
</div>
</form>
现在,当您按Enter键时,它将调用onserverclick="GetDistributorRegNo"
并将表单数据发送到服务器。
编辑:您的代码背后应该看起来像这样接收表单数据
protected void Page_Load(Object Source, EventArgs E)
{
if (IsPostBack)
{
// Process Form data here...
}
}