我正在开发一个呈现 (a) textbox
(es) 的自定义控件,textchange event
我想将值异步发送到控件,在那里它将搜索并使数据在公开的属性中可用,以便稍后获取page load
。但我的问题是,如何异步调用在我的控件内编码的方法来执行搜索功能。现在,textbox textchange
和buttons click events
没有触发,按钮单击加载页面并且在文本框中写入什么都不做。这是代码。
public int Count { get; set; }
public List<object> Selection { get; set; }
public object SelectedObject { get; set; }
public Label label;
public TextBox textBox;
protected override void RenderContents(HtmlTextWriter output)
{
textBox = new TextBox();
textBox.TextChanged += new EventHandler(Method);
UpdatePanel up = new UpdatePanel();
up.ID = "UpdatePanel1";
up.ChildrenAsTriggers = true;
up.UpdateMode = UpdatePanelUpdateMode.Conditional;
up.ContentTemplateContainer.Controls.Add(a);
this.label = new Label();
this.label.Text = "Initialized Text.";
up.ContentTemplateContainer.Controls.Add(this.label);
Button button = new Button();
button.Text = "Say Hello";
button.Click += new EventHandler(HandleButtonClick);
up.ContentTemplateContainer.Controls.Add(button);
this.Controls.Add(up);
foreach (Control c in this.Controls)
{
c.RenderControl(output);
}
}
private List<object> Get(string searchValue)
{
throw new NotImplementedException();
}
public void Method(object sender, EventArgs e) {
(sender as TextBox).Text += " ";
//Selection = Get((sender as TextBox).Text);
}
private void HandleButtonClick(object sender, EventArgs e)
{
this.label.Text = "Hello " + this.textBox.Text;
//Selection = Get(this.textBox.Text);
}