|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need Click Event to Fire from TextBoxI know that the current System.Web.UI.WebControls.TextBox doesn't currently
have a Click event associated with it, but I need it to for my current application. What is the fastest/easiest way to add the Click event to the textbox????? What would you do with the click event in a textbox? Do you mean OnFocus?
Show quoteHide quote "RBrady" <RBr***@discussions.microsoft.com> wrote in message news:0548BA1B-D319-4B3A-BE19-85F3FF532DE6@microsoft.com... >I know that the current System.Web.UI.WebControls.TextBox doesn't currently > have a Click event associated with it, but I need it to for my current > application. What is the fastest/easiest way to add the Click event to > the > textbox????? Yes...onFocus or onClick.....
I'm building an ASP.Net application that will be utilized by a touchscreen interface. (A web based kiosk, if you will) To get past the TextBox only having the OnTextChanged event, I used ImageButtons near each one of the TextBoxes, and clicking on one of these will force the keyboard web control to add text to the appropriate item. Now, my manager wants me to enable the ability for the users to also click on the TextBox to also tell the keyboard what to do. I already have the event handlers for the keyboard now, and I just want to add an event to the TextBoxes when you click in them to allow me to wire to the handler in place. Known: A. The TextChanged event doesn't work for my situation. B. I tried creating a custom control derived from WebControl and was able to create a clickable textbox that posts back on the click, but I can not raise the "Click" event..... Thanks for any advice... Ryan Show quoteHide quote "Ken Cox [Microsoft MVP]" wrote: > What would you do with the click event in a textbox? Do you mean OnFocus? > > "RBrady" <RBr***@discussions.microsoft.com> wrote in message > news:0548BA1B-D319-4B3A-BE19-85F3FF532DE6@microsoft.com... > >I know that the current System.Web.UI.WebControls.TextBox doesn't currently > > have a Click event associated with it, but I need it to for my current > > application. What is the fastest/easiest way to add the Click event to > > the > > textbox????? > > Hi Ryan,
Interesting problem. I'm just brainstorming some ideas here, so don't consider this a solution yet. How about this idea: Make the client-side onfocus event kick off the server-side postback. It still looks messy, but it might get the creative juices flowing... Private Sub Page_Load _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then tb.Attributes.Add("onfocus", "__doPostBack('tb','')") tb.Attributes.Add("onblur", "__doPostBack('tb','')") Else tb.Attributes.Remove("onfocus") tb.Attributes.Remove("onblur") Label1.Text = "Got a postback at: " & _ Now.ToLongTimeString End If End Sub <form id="Form1" method="post" runat="server"> <p> <asp:textbox id="tb" runat="server"></asp:textbox></p> <p> <asp:label id="Label1" runat="server"></asp:label></p> <p> <asp:textbox id="TextBox1" runat="server" AutoPostBack="True"></asp:textbox></p> </form> Show quoteHide quote "RBrady" <RBr***@discussions.microsoft.com> wrote in message news:DFC0A910-550C-421A-9D8F-ABC1BCC2116D@microsoft.com... > Yes...onFocus or onClick..... > > I'm building an ASP.Net application that will be utilized by a touchscreen > interface. (A web based kiosk, if you will) > To get past the TextBox only having the OnTextChanged event, I used > ImageButtons near each one of the TextBoxes, and clicking on one of these > will force the keyboard web control to add text to the appropriate item. > > Now, my manager wants me to enable the ability for the users to also click > on the TextBox to also tell the keyboard what to do. I already have the > event handlers for the keyboard now, and I just want to add an event to > the > TextBoxes when you click in them to allow me to wire to the handler in > place. > > Known: > A. The TextChanged event doesn't work for my situation. > B. I tried creating a custom control derived from WebControl and was able > to > create a clickable textbox that posts back on the click, but I can not > raise > the "Click" event..... > > > Thanks for any advice... > > Ryan > > "Ken Cox [Microsoft MVP]" wrote: > >> What would you do with the click event in a textbox? Do you mean OnFocus? >> >> "RBrady" <RBr***@discussions.microsoft.com> wrote in message >> news:0548BA1B-D319-4B3A-BE19-85F3FF532DE6@microsoft.com... >> >I know that the current System.Web.UI.WebControls.TextBox doesn't >> >currently >> > have a Click event associated with it, but I need it to for my current >> > application. What is the fastest/easiest way to add the Click event to >> > the >> > textbox????? >> >> Ok...So I found a workaround to this problem, but I still think it would have
been far less code to have a TextBox.OnFocus or OnClick Event, and I'm still interested in finding out the answer to the original query. How I worked around this was to add a javascript function to set a hidden field's value and submit the form. On the server side, I pulled the value out of the Request and wrote a switch testing the value of that string. Depending on the string value, I called the same functions called by the event handlers set up for my server control events. An additional questions: 1) Can anyone offer an explanation or SWAG at why the design of the TextBox modeled some of the Html text input events and not others? 2) Does anyone with ASP.Net 2.0 experience know if the TextBox control in that version implements an onClick or onFocus event? Thanks, Ryan Show quoteHide quote "RBrady" wrote: > I know that the current System.Web.UI.WebControls.TextBox doesn't currently > have a Click event associated with it, but I need it to for my current > application. What is the fastest/easiest way to add the Click event to the > textbox????? > 2) Does anyone with ASP.Net 2.0 experience know if the TextBox control in It doesn't look like anything has changed:> that version implements an onClick or onFocus event? http://msdn2.microsoft.com/library/d0chd93e.aspx Ken,
Thanks for looking into my problem and responding... Ryan Show quoteHide quote "Ken Cox [Microsoft MVP]" wrote: > > 2) Does anyone with ASP.Net 2.0 experience know if the TextBox control in > > that version implements an onClick or onFocus event? > > It doesn't look like anything has changed: > > http://msdn2.microsoft.com/library/d0chd93e.aspx > > >
Other interesting topics
Customizing ASP.NEt Hyperlink Control
IE Web Controls - discontinued ??? custom validator and button events custom validator and button events Urgent! GridView and templated controls binding---------Plz help Control Template How do I post hidden variables to another form from a popup? Sorting problem in Data grid control dataset values in a dropdownlist Stop datagrid causing validation |
|||||||||||||||||||||||