Determining the focus point on a page

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top