Avatar of attipa
attipaFlag for United States of America

asked on 

assigning enter keyboard button to imagebutton

i have the following code:

<asp:textbox id=searchbox runat=server />
<asp:imagebutton id=searchbutton runat=server imageurl=search.gif />

how can i make the enter button on the keyboard do the click method for the imagebutton?  it has nothing to do with the codebehind....i am trying to assing the enter button on the keyboard to work when someone types in the textbox, to fire the imagebutton
ASP.NET

Avatar of undefined
Last Comment
attipa
ASKER CERTIFIED SOLUTION
Avatar of Ajay Sharma
Ajay Sharma
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of attipa
attipa
Flag of United States of America image

ASKER

it did not work...
Avatar of Ajay Sharma
Ajay Sharma
Flag of India image

try the links.

if still no luck then post the error
Avatar of MikeMCSD
MikeMCSD
Flag of United States of America image

This is how I do it and it works. Use the "text changed" event for textbox.
Put the code you want to run in the ExecuteSearch() sub:

Private Sub searchbox _TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles searchbox .TextChanged
      ExecuteSearch()
End Sub

Private Sub searchbutton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles searchbutton.Click
      ExecuteSearch()
End Sub

Private Sub ExecuteSearch()
      If Trim(searchbox .Text) <> "" Then
         ' Your Code you want to run . . . . . . .
        ..................
      End If
End Sub
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo