* javascript *
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
---------------------------------------------------------------------------------------------------------
* JavaScript Function *
<script type="text/javascript">
$(function() {
$(".tb").autocomplete({
source: function(request, response) {
$.ajax({
url: "Report/AuroCompleteService.asmx/GetMemberName",
data: "{ 'MemberName': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function(data) { return data; },
success: function(data) {
response($.map(data.d, function(item) {
return {
value: item
}
}))
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
minLength: 2
});
});
</script>
-------------------------------------------------------------------------------------------------------
* Html Code *
<div class="demo">
<div class="ui-widget">
<label for="tbAuto">
Enter Email:
</label>
<asp:TextBox ID="tbAuto" class="tb" runat="server">
</asp:TextBox>
</div>
</div>
---------------------------------------------------------------------------------------------------------
* Add Web Service file*
AuroCompleteService.cs
Put below Code in this file
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] GetMemberName(string MemberName)
{
DataTable _dtMemberName = SBusinessLayer.Member.GetAllProfile(0, MemberName);
string[] _MemberName = new string[0];
if (_dtMemberName.Rows.Count > 0)
{
//return _dtMemberName.Rows[0][0].ToString();
int _i = 0;
foreach (DataRow _drMemberName in _dtMemberName.Rows)
{
Array.Resize<string>(ref _MemberName, _i + 1);
_MemberName.SetValue(_drMemberName["MemberName"], _i);
_i = _i + 1;
}
return _MemberName;
}
else
{
return _MemberName;
}
}
---------------------------------------------------------------------------------------------------------
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
---------------------------------------------------------------------------------------------------------
* JavaScript Function *
<script type="text/javascript">
$(function() {
$(".tb").autocomplete({
source: function(request, response) {
$.ajax({
url: "Report/AuroCompleteService.asmx/GetMemberName",
data: "{ 'MemberName': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function(data) { return data; },
success: function(data) {
response($.map(data.d, function(item) {
return {
value: item
}
}))
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
},
minLength: 2
});
});
</script>
-------------------------------------------------------------------------------------------------------
* Html Code *
<div class="demo">
<div class="ui-widget">
<label for="tbAuto">
Enter Email:
</label>
<asp:TextBox ID="tbAuto" class="tb" runat="server">
</asp:TextBox>
</div>
</div>
---------------------------------------------------------------------------------------------------------
* Add Web Service file*
AuroCompleteService.cs
Put below Code in this file
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] GetMemberName(string MemberName)
{
DataTable _dtMemberName = SBusinessLayer.Member.GetAllProfile(0, MemberName);
string[] _MemberName = new string[0];
if (_dtMemberName.Rows.Count > 0)
{
//return _dtMemberName.Rows[0][0].ToString();
int _i = 0;
foreach (DataRow _drMemberName in _dtMemberName.Rows)
{
Array.Resize<string>(ref _MemberName, _i + 1);
_MemberName.SetValue(_drMemberName["MemberName"], _i);
_i = _i + 1;
}
return _MemberName;
}
else
{
return _MemberName;
}
}
---------------------------------------------------------------------------------------------------------
No comments:
Post a Comment