Here'a a cheap and cheerful answer for two textboxes and two buttons, and it's in VB - but I'm sure you are quite capable of extending it and translating it to C#... purists may grind their teeth, but hey, it works, and that's what counts, right? ;P <%@ Page Language="VB" %> Sub Page_Load(Sender As Object, e As EventArgs) If Not Page.IsPostBack Then Textbox1.Attributes.Add("onblur","document.f1.hidTb.value='';") Textbox2.Attributes.Add("onblur","document.f1.hidTb.value='';") Textbox1.Attributes.Add("onfocus","document.f1.hidTb.value='Textbox1';") Textbox2.Attributes.Add("onfocus","document.f1.hidTb.value='Textbox2';") End If End Sub Sub Submit(Sender As Object, e As EventArgs) If hidTb.Text = "" Then If Sender.ID = "Button1" Then Proc_1() Exit Sub End If If Sender.ID = "Button2" Then Proc_2() Exit Sub End If End If If hidTb.Text = "Textbox1" Then Proc_1() Exit Sub End If If hidTb.Text = "Textbox2" Then Proc_2() Exit Sub End If End Sub Sub Proc_1() ' code to execute when Submit1 is clicked, or 'Enter' hit when focus is in textbox1 lblMsg.Text = "You clicked Submit1 or hit your Enter key while Textbox1 had the focus" End Sub Sub Proc_2() ' code to execute when Submit2 is clicked, or 'Enter' hit when focus is in textbox2 lblMsg.Text = "You clicked Submit2 or hit your Enter key while Textbox2 had the focus" End Sub
Bos 1: