c# visual Studio 2010
how can I capture the text from last TextBox control that had focus on a click of a button. thanks TIA
c# visual Studio 2010
how can I capture the text from last TextBox control that had focus on a click of a button. thanks TIA
I would use some javascript (jQuery) to do this easily by dumping that value into a hidden input onblur.
<input type="hidden" id="last" name="last" value="" />
$(function(){
$("input:text").blur(function(){
$("#last").val($(this).val());
});
});
Then pull this value from your button event.
I'm assuming this is ASP.Net, if not, then its even easier with Windows Forms
If this is Winforms, I believe you would have to assign the text of the last clicked textbox to a member variable when the textbox gets the focus (the GotFocus event). You would have to hook every textbox this way.
private void MyTextBox1_GotFocus(Object sender, EventArgs e) {
this.textFromTextboxLastClicked = MyTextBox1.Text;
}
Whether it's ASP.NET or WinForms, you have to attach an event to every TextBox. The function called during that event would keep the last TextBox (or the actual text, up to you). You could use the onblur (ASP.NET) or Leave (WinForms) events.