Javascript Auto Extender :
Example :
[WebMethod]
public static List<string> Get_Uom_Details(string UOMPack)
{
List<string> li = new List<string>();
li = get_uom(ref prefix);
return li;
}
public List<string> get_uom(ref string prefix)
{
using(conn = new SqlConnection (constr))
{
conn.Open();
SqlCommand cmd = new SqlCommand(@"sp_get_Pack_Material_Details_UOM", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@SearchText", prefix);
SqlDataReader dr = cmd.ExecuteReader();
List<string> li = new List<string>();
while(dr.Read())
{
li.Add(dr[0].ToString());
}
return li;
}
}
Script :
<script type="text/javascript">
public static List<string> Get_Uom_Details(string UOMPack)
{
List<string> li = new List<string>();
li = get_uom(ref prefix);
return li;
}
public List<string> get_uom(ref string prefix)
{
using(conn = new SqlConnection (constr))
{
conn.Open();
SqlCommand cmd = new SqlCommand(@"sp_get_Pack_Material_Details_UOM", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@SearchText", prefix);
SqlDataReader dr = cmd.ExecuteReader();
List<string> li = new List<string>();
while(dr.Read())
{
li.Add(dr[0].ToString());
}
return li;
}
}
Script :
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
$(document).ready(function () {
SearchOrder();
});
function SearchOrder() {
$("[id$=txtUOMPack]").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Cold_Storage_Stock_Update_Own.aspx/Get_Uom_Details",
data: "{'UOMPack':'" + $("[id$=txtUOMPack]").val() + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("No Match");
}
});
}
});
}
}
);
</script>
No comments:
Post a Comment