TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepak M
1.2k
546
36.5k
Unknown web method GetBankNames.
Dec 20 2019 4:04 AM
Web Service
namespace
WebApp1.Services
{
/// <summary>
/// Summary description for WebAppService
/// </summary>
[WebService(Namespace =
"http://localhost/"
)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(
false
)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[ScriptService]
public
class
WebAppService : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public
static
List<
string
> GetBankNames(
string
pre)
{
List<
string
> listBanks =
new
List<
string
>();
DataTable dtData =
new
DataTable();
string
conString = ConfigurationManager.ConnectionStrings[
"dbConnection"
].ConnectionString;
SqlConnection sqlCon =
new
SqlConnection(conString);
sqlCon.Open();
SqlCommand sqlCmd =
new
SqlCommand(
"Select BankId, BankName From BankMaster Where BankName Like '%' + @SearchText + '%'"
, sqlCon);
sqlCmd.Parameters.AddWithValue(
"@SearchText"
, pre);
SqlDataAdapter sqlDa =
new
SqlDataAdapter(sqlCmd);
sqlDa.Fill(dtData);
sqlCon.Close();
if
(dtData.Rows.Count > 0)
{
for
(
int
i = 0; i < dtData.Rows.Count; i++)
{
listBanks.Add(
string
.Format(
"{0}-{1}"
, dtData.Rows[i][
"BankName"
], dtData.Rows[i][
"BankId"
]));
}
}
return
listBanks;
}
}
}
Script
<script type=
"text/javascript"
>
$(
function
() {
$(
'#<%=txtAutoComplete.ClientID%>'
).autocomplete({
minLength: 1,
source:
function
(request, response) {
$.ajax({
url:
"Services/WebAppService.asmx/GetBankNames"
,
data:
"{ 'pre':'"
+ request.term +
"'}"
,
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) {
alert(response.responseText);
},
failure:
function
(response) {
alert(response.responseText);
}
});
},
select:
function
(e, i) {
$(
"[id$=hfBankId]"
).val(i.item.val);
},
});
});
</script>
When ever i call the web service always get error as "Unknown web method GetBankNames".
Reply
Answers (
2
)
i have an issue in email scheduling in web application
What is a principle tool(Google map)