$('#btnSearch').click(function () { alert('in search function'); $.ajax({ type: "POST", url: location.pathname + "SearchFromHome.asmx/SearchFromHomeBus", data: "{fromid:'" + 1 + "' , toid:'" + 2 + "'}", dataType: "json", contentType: "application/json; charset=utf-8", success: SearchSuccess, error: SearchError }); function SearchSuccess(data) { alert("you searched for "); var result = "<table>"; result += "<th> " + "<td>Model</td>" + "<td>Companyname</td>" + "<td>Image</td>" + "<td>capacity</td>" + "<td>Ac/km</td>" + "<td>NonAc/km</td>" + "<td>Ac/day</td>" + "<td>NonAc/day</td>" + " </th>"; for (var i = 0; i < data.d.length; i++) { result += "<tr>"; result += "<td>"; result += data.d[i].model; result += "</td>"; result += "<td>"; result += data.d[i].CompanyName; result += "</td>"; result += "<td>"; result += "<img height='75px' width='100px' src='../../Themes/cars/" + data.d[i].CabImage + "' />" //result += data.d[i].CabImage; result += "</td>"; result += "<td>"; result += data.d[i].Capacity; result += "</td>"; result += "<td>"; result += data.d[i].ACperkm; result += "</td>"; result += "<td>"; result += data.d[i].NonACperkm; result += "</td>"; result += "<td>"; result += data.d[i].ACperDay; result += "</td>"; result += "<td>"; result += data.d[i].NonACperDay; result += "</td>"; result += "</tr>"; } result += "</table>"; $("#searchResult").append(result); $("#SearchNewPage").html(result); } function SearchError() { alert("Error in search"); } });
[WebMethod] public IEnumerable<CitySearchResult> SearchFromHomeBus(int fromid, int toid) { // DbDataReader sqlreader; SqlParameter []para=new SqlParameter[2]; para[0]=new SqlParameter("@city1",fromid); para[1]=new SqlParameter("@city2",toid); using (cab_4_21Entities1 d = new cab_4_21Entities1()) { ObjectResult<CitySearchResult> search =d.ExecuteStoreQuery<CitySearchResult>("usp_SearchcabResult @city1, @city2", para); //List<CitySearchResult> search = (d.ExecuteStoreQuery<CitySearchResult>("usp_SearchcabResult", para)).ToList<CitySearchResult>(); List<CitySearchResult> searchResult=search.ToList<CitySearchResult>(); return searchResult; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)