473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to identify the control when User uses the Enter Key

Hi

I am building a Search Interface.It has two text boxes (box1 and box2) and
two buttons (btnbox1 and btnbox2) in the ASPX page.

Example
User keys in a search text in box2 and presses the Enter key. How to
identify that page was submitted becoz the User pressed the enter key when he
was in box2.

Currently in the page load I see which box is empty and then take respective
action but this is not desirable.
Kindly let me if this can be achieved.

Regards
Vishwanathan
Nov 19 '05 #1
2 1418
You could use this free control to solve the problem.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Vishwanathan Raman" <Vi***************@discussions.microsoft.com> wrote in
message news:EB**********************************@microsof t.com...
Hi

I am building a Search Interface.It has two text boxes (box1 and box2) and
two buttons (btnbox1 and btnbox2) in the ASPX page.

Example
User keys in a search text in box2 and presses the Enter key. How to
identify that page was submitted becoz the User pressed the enter key when
he
was in box2.

Currently in the page load I see which box is empty and then take
respective
action but this is not desirable.
Kindly let me if this can be achieved.

Regards
Vishwanathan

Nov 19 '05 #2
hi Vishwanathan,

If i understand your problem properly, you want click button 2 when user is
in box2 and press enter and same for text box 1/button 2 combination.

If this is the problem, then the solution is pretty simple.
server side:
textbox1.Attributes.add("onkeypress","ClickAddButt on('button1');")
textbox2.Attributes.add("onkeypress","ClickAddButt on('button2');")

javascript:
function ClickAddButton(buttonId)
{
if(event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;

document.getElementById(buttonId).click();
}
}

regards
Ural
"Vishwanathan Raman" wrote:
Hi

I am building a Search Interface.It has two text boxes (box1 and box2) and
two buttons (btnbox1 and btnbox2) in the ASPX page.

Example
User keys in a search text in box2 and presses the Enter key. How to
identify that page was submitted becoz the User pressed the enter key when he
was in box2.

Currently in the page load I see which box is empty and then take respective
action but this is not desirable.
Kindly let me if this can be achieved.

Regards
Vishwanathan

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: DraguVaso | last post by:
Hi, I want my application do different actions depending on the exception it gets. For exemple: I have an SQL-table with a unique index. In case I try to Insert a record that's alreaddy in it I...
0
by: Yoshitha | last post by:
Hi, I want help regarding providing information about form and controls which are presented on the form. when ever user presses f1 if the form has focus then it has to provide information about...
6
by: Alan Silver | last post by:
Hello, After much battling, I think I am finally seeing some progress on my first user control (thanks to the patient souls who have answered my many questions!!). I am left with one more...
7
by: Grant Merwitz | last post by:
Hi I am trying to get the enter key to submit my login form The login form is currently in a control on the page and uses an asp:imagebutton as it's login button. If a user presses enter...
2
by: Web Team | last post by:
Hi All, I'm in the process of writing a eich text editor web custom control. The actual text/HTML is displayed/editied in a DIV layer, which I have created like this: output.Write("<span...
10
by: Dennis D. | last post by:
Hello: There are a series of textboxes (x.text, y.text, z.text etc.) in which user input is expected. As: dtmX=CDate(x.text) dtmY=CDate(y.text) dtmZ=CDate(z.text) where x, y, and z.text...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
I want to build an simple email smtp client app similar to outlook except with some custom features for a personal computer that uses comcast cable. The owner of the computer said she doesn't have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.