如何在后台(.cs文件中)动态添加Ajax中的AutoCompleteExtender(自动完成)控件?
如题:
我在页面中放置了两个TextBox文本框,TextBox1采取直接添加AutoCompaleteExtender的方法,TextBox2则采取在后台动态添加的方法,调试运行时,第一个一切正常,第二个没有反应。不知道是什么原因,代码如下:
Default2.aspx文件:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default2.aspx.cs " Inherits= "Default2 " %>
<%@ Register Assembly= "AjaxControlToolkit " Namespace= "AjaxControlToolkit " TagPrefix= "cc1 " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:ScriptManager ID= "ScriptManager1 " runat= "server ">
</asp:ScriptManager>
<asp:UpdatePanel ID= "UpdatePanel1 " runat= "server ">
<ContentTemplate>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<cc1:AutoCompleteExtender ID= "AutoCompleteExtender1 " runat= "server " TargetControlID= "TextBox1 "
ServicePath= "~/Journey_Manage/AutoCompleteWebService.asmx "
ServiceMethod= "GetJourneyCity "
MinimumPrefixLength= "2 "
CompletionInterval= "100 "
EnableCaching= "true "
CompletionSetCount= "10 ">
</cc1:AutoCompleteExtender>
<asp:TextBox ID= "TextBox2 " runat= "server "> </asp:TextBox>
</Conten