This the code in my .aspx page and I am using auto complete for textbox.
<script type="text/javascript">
$(document).ready(function () {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Preferences.aspx/GetAutoCompleteData",
data: "{'Name':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
}
});
}
</script>
<table style="width:auto">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Please Type Student Name:"></asp:Label>
</td>
<td>
<input type="text" id="txtSearch" class="autosuggest" />
<asp:TextBox ID="TextBox1" runat="server" Text=txtsearch Visible="true" class="autosuggest"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
</td>
</tr>
</table>
If I put runat="Server" in
<input type="text" id="txtSearch" class="autosuggest" />
then auto complete doesn't work. Form tag is used in master page.
Problem Solved using the name property of control
Source Code:
<input type="text" name="_name" />
<asp:Button ID="btnShow" runat="server" Text="Show" onclick="btnShow_Click" />
CodeBehind:
protected void btnShow_Click(object sender, EventArgs e)
{
string strValue = Page.Request.Form["_name"].ToString();
Response.Write(strValue);
}
Reference: http://www.etechpulse.com/2013/02/get-html-input-controls-value-server.html
Thanks guys for your help.