Click here to Skip to main content
12,070,030 members (28,357 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP ASP.NET C#4.0
i have a textbox_Search in my webform
i want when i press Enter this txtbox redirect to other page
i want redirect to other webform with press enter
and textbox_search.text go to sesseion .
get e.keycode or e.keychar
i want only a C# code
C#
C#
i have a txtbox(search txt) in my webform
i want when i press a key
if that key is enter(press enter)
redirect to another webform
for example ;
in this site(codeproject)
when enter a text in txt (search site)(on top right) and if press enter
site go to another page and show search resault
i want accour this action
a want know when key is enter
Posted 18-Jun-12 10:04am
Edited 18-Jun-12 10:50am
v3
Comments
SAKryukov 18-Jun-12 15:26pm
   
"Want only a C# code" is not a question. What's the problem?
--SA
sadegh_rusta 18-Jun-12 15:41pm
   
i have a txtbox(search txt) in my webform
i want when i press a key
if that key is enter(press enter)
redirect to another webform
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I think that what you want to do is get the string value instead of the Keys value. Just use ToString().

If you want a particular key with the KeyDown check against one of the Keys enumeration:

if (e.KeyChar == Keys.Enter)
  Permalink  
v2
Comments
sadegh_rusta 18-Jun-12 15:47pm
   
no
Sandeep Mewara 18-Jun-12 16:06pm
   
In ASP.NET web server side?

If we have to go through keycode route, then I would prefer via client side code and handle it in JavaScript.
Clifford Nelson 18-Jun-12 17:35pm
   
Don't know, it works in WinForms, and I have not done enough asp.net to know.
Vasim889 19-Jun-12 1:37am
   
it's not windows application .it's web application so you only use javascript use to trace enter key action.key event not found in server side.
Clifford Nelson 19-Jun-12 14:25pm
   
Understood, sorry I could not be of help. Not sure where what I know can be of help, but thought I would try.
sadegh_rusta 19-Jun-12 8:56am
   
i have a webform ,i dont have window application
Clifford Nelson 19-Jun-12 13:06pm
   
I have only done limited work in ASP.NET, so never got this deep into it. Sorry could not help
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

i have a txtbox(search txt) in my webform i want when i press a key if that key is enter(press enter) redirect to another webform
Based on the comment given by you to SA, you need a submit button with default focus on it. In ASP.NET, it's termed as "Default Button"

Refer:
ASP.NET DefaultButton Property[^]
Sample usage of Default button[^]

No need of any key code or so. Using above, default behavior of enter press would direct it as defined for that button click.
  Permalink  
Comments
sadegh_rusta 19-Jun-12 8:56am
   
no i have onlya txt box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 23 Dec 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100