0

Let say i hv two textbox, i.e. TextBox1 and TextBox2 and a button. Is it possible for me to write text into either Textbox1 or TextBox2 when the focus is at the textbox and button is clicked subsequently?

For example my focus is now at TextBox1 then i clicked on the button. TextBox1 is filled with "abc".

Is it possible for me to do that?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by sknake
0

Even if the focus is in TextBox1, after clicking the button, the focus moves to the button(TextBox1 will lose the focus). Therefore write code for the onclick event of the button to fill 'abc' to TextBox1 and set the focus again to the TextBox1.

0

I think you could use javascript to 'record' the last focused textbox and grab that information client side and populate the textBox. If you're wanting the button to populate the text on a server side postback then you could use a hidden form field to pass back the last focused text box.

0

If this is the case, how do i determine the last focus with C#?

0

You don't. You need to find some javascript code that does this. You're wanting to know client-side focus and C# is server-side language.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.