Please Use webservice for this problem.
<asp:textbox id="txtlocation" runat="server" height="25px" cssclass="input-medium " style="display:none;" xmlns:asp="#unknown">
<script>
$(document).ready(function () {
Location();
});
</script></script>
Using this script for send your request.
function Location() {
$("#txtlocation").autocomplete({
source: function (request, response) {
$.ajax({
url: 'WebService_SearchBox.asmx/GetLocation',
data: "{ 'prefix': '" + request.term + "','CurrURL':'" + window.location.pathname + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
},
failure: function (response) {
}
});
},
select: function (e, i) {
$("#hdfCity").val(i.item.val);
LocationCookies(i.item.val);
},
minLength: 1
});
};
create a webservice and follow the code.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool GetLocAuto(Int32 country_id, Int32 state_id, Int32 city_id)
{
string strResult = ""; bool isset = false;
strResult = country_id.ToString() + "#" + state_id.ToString() + "#" + city_id.ToString();
try
{
HttpCookie City_ID = new HttpCookie("LocName", strResult);
City_ID.Expires = DateTime.Now.AddHours(3);
Context.Response.SetCookie(City_ID);
isset = true;
}
catch (Exception)
{ }
return isset;
}