有一个显示检索到的值的 ascx 控件。想用一个文本输入框来post back as value changes

Have an ascx control with retrieved values displayed. Want to use a text input box to post back as value changes

所以我正在做一些事情,涉及从某种文本输入中获取用户输入,并在用户输入框中时触发事件以动态更新显示的列表。

我的特殊挂断是弄清楚如何在 html 中显示输入文本框,并在每次用户输入或删除字符时将其 post 返回到后面的代码(基本上,每当文本的值发生变化时)更新我的列表。

我最初尝试查看 HtmlInputText,但它本身没有做任何 post,所以我认为这不是我要找的。

我应该关注什么类型的元素和交互?

谢谢!

您应该使用 OnTextChanged 函数调用后面的代码并将 AutoPostBack 设置为 true。

<asp:TextBox ID="InputBox1" runat="server" OnTextChanged="InputBox1_TextChanged" AutoPostBack="true"></asp:TextBox>

代码隐藏

 protected void InputBox1_TextChanged(object sender,EventArgs e)
    {
         //You're code here
    }