Click here to Skip to main content
Rate this: bad
good
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 9:04am
Edited 18-Jun-12 9:50am
v3
Comments
SAKryukov at 18-Jun-12 15:26pm
   
"Want only a C# code" is not a question. What's the problem?
--SA
sadegh_rusta at 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 at 18-Jun-12 15:47pm
   
no
Sandeep Mewara at 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 at 18-Jun-12 17:35pm
   
Don't know, it works in WinForms, and I have not done enough asp.net to know.
Vasim889 at 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 at 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 at 19-Jun-12 8:56am
   
i have a webform ,i dont have window application
Clifford Nelson at 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 at 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
0 OriginalGriff 527
1 CPallini 510
2 Sergey Alexandrovich Kryukov 438
3 George Jonsson 271
4 Afzaal Ahmad Zeeshan 184
0 OriginalGriff 5,370
1 CPallini 4,360
2 Sergey Alexandrovich Kryukov 3,822
3 George Jonsson 3,037
4 Gihan Liyanage 2,435


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2014
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