[英]How can i solve this; Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified
I want to mask for phone number.我想屏蔽电话号码。 I tried to use Ajax Control Tool Kit - MaskedEditExtender for this.为此,我尝试使用 Ajax Control Tool Kit - MaskedEditExtender。 I downloaded Ajax Control Tool Kit from Nuget. On the Aspx page, I added the code I found on the inte.net, where the error was given below.我从Nuget下载了Ajax Control Tool Kit,在Aspx页面上,我添加了我在inte.net上找到的代码,错误如下。 But I don't know how to solve this error.但我不知道如何解决这个错误。 Can you help me?你能帮助我吗?
Ok, so say we want to autocomplete a text box (against say the database).好的,假设我们要自动完成一个文本框(反对说数据库)。
so, we would first do a nuget of ajaxtoolkit.所以,我们首先要做一个 nuget 的 ajaxtoolkit。
Then, we drop a text box on a form.然后,我们在表单上放置一个文本框。
We should see this - say this markup:我们应该看到这个 - 说这个标记:
Then we now click on the text box in the designer.然后我们现在单击设计器中的文本框。
And then然后
so, now our markup is this:所以,现在我们的标记是这样的:
<h3>enter hotel Name</h3>
<asp:TextBox ID="txtHotel" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="txtHotel_AutoCompleteExtender"
runat="server" BehaviorID="txtHotel_AutoCompleteExtender" DelimiterCharacters=""
TargetControlID="txtHotel"
ServiceMethod = "SearchCustomers"
MinimumPrefixLength = "1"
CompletionInterval="100"
EnableCaching="false"
CompletionSetCount="10" >
</ajaxToolkit:AutoCompleteExtender>
Note that I displayed the property sheet, and filled out the above values.请注意,我显示了属性表,并填写了以上值。 (remove the ServicePath="" - you don't need it). (删除 ServicePath="" - 你不需要它)。
so, now our code behind:所以,现在我们的代码背后:
// using System.Web.Services;
[WebMethod()]
public static List<string> SearchCustomers(string prefixText, int count)
{
List<string> customers = new List<string>();
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.TEST4))
{
string strSQL
= "select HotelName FROM tblHotels WHERE HotelName like @SearchText + '%' ORDER BY HotelName";
using (SqlCommand cmd = new SqlCommand(strSQL, conn))
{
cmd.Parameters.Add("@SearchText", SqlDbType.NVarChar).Value = prefixText;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
customers.Add(sdr["HotelName"].ToString());
}
}
}
return customers;
}
And now we get this:现在我们得到这个:
So, you create a web method in the code behind.因此,您在后面的代码中创建了一个 web 方法。
Somehow, I posted the wrong info and answer for this quesiton.不知何故,我为这个问题发布了错误的信息和答案。
However, for a edit mask?但是,对于编辑蒙版?
Then again, drop in a text box, extender - edit mask.然后再次放入文本框,扩展器 - 编辑蒙版。
So, say this:所以,这样说:
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
and then:然后:
We now have this for the markup:我们现在有这个标记:
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<ajaxToolkit:MaskedEditExtender ID="TextBox1_MaskedEditExtender"
runat="server" BehaviorID="TextBox1_MaskedEditExtender"
TargetControlID="TextBox1" Mask="(999)-999-9999" />
Doing above, should insert (add) to the page at the top this:执行上述操作时,应将此插入(添加)到页面顶部:
<%@ Register assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit"
tagprefix="ajaxToolkit" %>
And now when we enter that textbox, you get this:现在当我们输入那个文本框时,你会得到这个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.