此 web 方法仅适用于第一个文本框,不适用于所有三个文本框。我发现这也太慢了,因为 1 个文本框正在工作而其他 2 个不工作
This webmethod is only working for 1st textbox not for all three. I found this too slow also as 1 textbox is working and other 2 is not working
//asp.net代码
这是asp.net
的代码
In this code i don't know how to use all three webmethods please help me in this.
Is it really possible i can done this thing with 1 webmethod
In this code i don't know how to use all three webmethods please help me in this.
Is it really possible i can done this thing with 1 webmethod
like so
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label class="control-label" for="sel15">Activity</label>
<asp:TextBox ID="actvity" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="GetListofCountries" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="actvity">
</cc1:AutoCompleteExtender>
</div>
</div>
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label class="control-label" for="sel15">Reference No.</label>
<asp:TextBox ID="refre" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="refrencenumber" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="refre">
</cc1:AutoCompleteExtender>
</div>
</div>
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label>Invoice No.</label>
<asp:TextBox ID="invoiceno" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="invoicenumber" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="invoiceno">
</cc1:AutoCompleteExtender>
</div>
</div>
//asp.net code
like so
//网络方法
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetListofCountries(string prefixText)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul = "Select distinct project_name from mis_projects_master where project_name ilike '%" + prefixText + "%' ";
DataTable dt = dl.executeGetData(queryfetchconsul);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i]["project_name"].ToString());
}
return CountryNames;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> refrencenumber(string prefixText1)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul1 = "Select distinct ref_number from mis_project_details where ref_number ilike '%" + prefixText1 + "%' ";
DataTable dt1 = dl.executeGetData(queryfetchconsul1);
List<string> CountryNames1 = new List<string>();
for (int i = 0; i < dt1.Rows.Count; i++)
{
CountryNames1.Add(dt1.Rows[i]["ref_number"].ToString());
}
return CountryNames1;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> invoicenumber(string prefixText2)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul2 = "Select distinct inv_no from mis_lumpsum_milestones_fin_progress where inv_no ilike '%" + prefixText2 + "%' ";
DataTable dt2 = dl.executeGetData(queryfetchconsul2);
List<string> CountryNames2 = new List<string>();
for (int i = 0; i < dt2.Rows.Count; i++)
{
CountryNames2.Add(dt2.Rows[i]["inv_no"].ToString());
}
return CountryNames2;
}
//webmethod
I have no idea why this happen please help me .
我觉得你的 class 上面少了 [System.Web.Script.Services.ScriptService],这样写
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class YourClass : System.Web.Services.WebService
{
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetListofCountries(string prefixText)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul = "Select distinct project_name from mis_projects_master where project_name ilike '%" + prefixText + "%' ";
DataTable dt = dl.executeGetData(queryfetchconsul);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i]["project_name"].ToString());
}
return CountryNames;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> refrencenumber(string prefixText1)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul1 = "Select distinct ref_number from mis_project_details where ref_number ilike '%" + prefixText1 + "%' ";
DataTable dt1 = dl.executeGetData(queryfetchconsul1);
List<string> CountryNames1 = new List<string>();
for (int i = 0; i < dt1.Rows.Count; i++)
{
CountryNames1.Add(dt1.Rows[i]["ref_number"].ToString());
}
return CountryNames1;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> invoicenumber(string prefixText2)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul2 = "Select distinct inv_no from mis_lumpsum_milestones_fin_progress where inv_no ilike '%" + prefixText2 + "%' ";
DataTable dt2 = dl.executeGetData(queryfetchconsul2);
List<string> CountryNames2 = new List<string>();
for (int i = 0; i < dt2.Rows.Count; i++)
{
CountryNames2.Add(dt2.Rows[i]["inv_no"].ToString());
}
return CountryNames2;
}
//webmethod
}
希望对您有所帮助。
//asp.net代码 这是asp.net
的代码In this code i don't know how to use all three webmethods please help me in this. Is it really possible i can done this thing with 1 webmethod
In this code i don't know how to use all three webmethods please help me in this. Is it really possible i can done this thing with 1 webmethod
like so
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label class="control-label" for="sel15">Activity</label>
<asp:TextBox ID="actvity" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="GetListofCountries" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="actvity">
</cc1:AutoCompleteExtender>
</div>
</div>
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label class="control-label" for="sel15">Reference No.</label>
<asp:TextBox ID="refre" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="refrencenumber" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="refre">
</cc1:AutoCompleteExtender>
</div>
</div>
<div class="col-xs-12 col-sm-3">
<div class="form-group">
<label>Invoice No.</label>
<asp:TextBox ID="invoiceno" runat="server" CssClass="form-control"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" CompletionListCssClass="srch_box" DelimiterCharacters="" Enabled="True" ServiceMethod="invoicenumber" MinimumPrefixLength="1" EnableCaching="true" TargetControlID="invoiceno">
</cc1:AutoCompleteExtender>
</div>
</div>
//asp.net code
like so
//网络方法
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetListofCountries(string prefixText)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul = "Select distinct project_name from mis_projects_master where project_name ilike '%" + prefixText + "%' ";
DataTable dt = dl.executeGetData(queryfetchconsul);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i]["project_name"].ToString());
}
return CountryNames;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> refrencenumber(string prefixText1)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul1 = "Select distinct ref_number from mis_project_details where ref_number ilike '%" + prefixText1 + "%' ";
DataTable dt1 = dl.executeGetData(queryfetchconsul1);
List<string> CountryNames1 = new List<string>();
for (int i = 0; i < dt1.Rows.Count; i++)
{
CountryNames1.Add(dt1.Rows[i]["ref_number"].ToString());
}
return CountryNames1;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> invoicenumber(string prefixText2)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul2 = "Select distinct inv_no from mis_lumpsum_milestones_fin_progress where inv_no ilike '%" + prefixText2 + "%' ";
DataTable dt2 = dl.executeGetData(queryfetchconsul2);
List<string> CountryNames2 = new List<string>();
for (int i = 0; i < dt2.Rows.Count; i++)
{
CountryNames2.Add(dt2.Rows[i]["inv_no"].ToString());
}
return CountryNames2;
}
//webmethod
I have no idea why this happen please help me .
我觉得你的 class 上面少了 [System.Web.Script.Services.ScriptService],这样写
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class YourClass : System.Web.Services.WebService
{
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetListofCountries(string prefixText)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul = "Select distinct project_name from mis_projects_master where project_name ilike '%" + prefixText + "%' ";
DataTable dt = dl.executeGetData(queryfetchconsul);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i]["project_name"].ToString());
}
return CountryNames;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> refrencenumber(string prefixText1)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul1 = "Select distinct ref_number from mis_project_details where ref_number ilike '%" + prefixText1 + "%' ";
DataTable dt1 = dl.executeGetData(queryfetchconsul1);
List<string> CountryNames1 = new List<string>();
for (int i = 0; i < dt1.Rows.Count; i++)
{
CountryNames1.Add(dt1.Rows[i]["ref_number"].ToString());
}
return CountryNames1;
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> invoicenumber(string prefixText2)
{
DataLayer.DAL dl = new DataLayer.DAL();
string queryfetchconsul2 = "Select distinct inv_no from mis_lumpsum_milestones_fin_progress where inv_no ilike '%" + prefixText2 + "%' ";
DataTable dt2 = dl.executeGetData(queryfetchconsul2);
List<string> CountryNames2 = new List<string>();
for (int i = 0; i < dt2.Rows.Count; i++)
{
CountryNames2.Add(dt2.Rows[i]["inv_no"].ToString());
}
return CountryNames2;
}
//webmethod
}
希望对您有所帮助。