I am developing a custom control which renders (a) textbox
(es), in its textchange event
I want to asynchronously send the value to the control where it would search and make the data available in an exposed property to be fetched later on page load
. But my problem is, HOW TO ASYNCHRONOUSLY CALL A METHOD CODED INSIDE MY CONTROL to do the search functionality. For now, the textbox textchange
and the buttons click events
are not firing, the button click loads the page and writing in the textbox does nothing. Here is the code.
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);
}