Click here to Skip to main content
15,301,841 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Updated 18-Jun-12 9:50am
v3
Comments
Sergey Alexandrovich Kryukov 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

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)
   
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
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.
   
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900