在“文本”框中键入文本时绑定asp控件

Bind the asp control while typing the text in Text box

本文关键字:文本 绑定 asp 控件      更新时间:2023-09-26

我有一个文本框和一个中继器控件。当用户在文本框中输入文本时,我需要将数据绑定到中继器控件。这应该在不点击回车键或鼠标点击的情况下进行。

中继器应与文本框中以给定字符串开头的名称绑定

有人有主意吗?

我假设您想要的是在中继器列的文本框中输入相同的值。您可以使用文本框的onchange事件来调用javascript并更新中继器。

ASPX

<asp:ScriptManager ID="ScriptManager1" runat="server" /> <div id="Container"> <asp:UpdatePanel runat="server" ID="UpdatePanel1" 
    OnLoad="UpdatePanel1_Load">   <ContentTemplate>
    <asp:Repeater runat="server" ID="rpt"></asp:Repeater>   </ContentTemplate> </asp:UpdatePanel>
<input type="text" id="Container" onkeyup='update(document.getElementById("Container").value)'>

JS-

function update(args)
{
__doPostBack('UpdatePanel1', args);
}

C#

  protected void UpdatePanel1_Load(object sender, EventArgs e)
    {
      //bind reapeter
    }

明白了…这个http://www.dotnettutorials.com/tutorials/ajax/ajax-search-csharp.aspx帮助我通过微小的改变获得我想要的东西。