M
MattC
I have the following piece of code in a method:
while(myReader.Read())
{
Button dynButton = new Button();
dynButton.Text = myReader["ExtendedCharacter"].ToString();
dynButton.Click += new System.EventHandler(this.Button_Click);
PlaceHolder1.Controls.Add(dynButton);
}
This will write out a list of dynamic button ad an event handler for each
one and then add the button to a placeholder on the webform.
Here is the event code:
private void Button_Click(object sender, System.EventArgs e)
{
this.Name.Text += ((Button)sender).Text;
}
nothing fancy just sets the text of the button into the textbox.
However, there will be multiple textboxes and i wish the text concatencation
to take place on teh textbox with the current focus.
So I require:
1.) the ability to determine which textbox has the to do the insert;
2.) set the focus back once the insert is done (as the focus is now set to
the button)
The only way I can think of doing this so far is to dynamically write out
client side javascript to handle the event of the click on a standard html
button and use that.
But surealy there much be a way oif acheiving this withought this rather
awkward method.
Any help is appreciated.
MattC
while(myReader.Read())
{
Button dynButton = new Button();
dynButton.Text = myReader["ExtendedCharacter"].ToString();
dynButton.Click += new System.EventHandler(this.Button_Click);
PlaceHolder1.Controls.Add(dynButton);
}
This will write out a list of dynamic button ad an event handler for each
one and then add the button to a placeholder on the webform.
Here is the event code:
private void Button_Click(object sender, System.EventArgs e)
{
this.Name.Text += ((Button)sender).Text;
}
nothing fancy just sets the text of the button into the textbox.
However, there will be multiple textboxes and i wish the text concatencation
to take place on teh textbox with the current focus.
So I require:
1.) the ability to determine which textbox has the to do the insert;
2.) set the focus back once the insert is done (as the focus is now set to
the button)
The only way I can think of doing this so far is to dynamically write out
client side javascript to handle the event of the click on a standard html
button and use that.
But surealy there much be a way oif acheiving this withought this rather
awkward method.
Any help is appreciated.
MattC