473,236 Members | 1,720 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,236 software developers and data experts.

Press enter fire specific button in form in ASP.Net 2

Howdy,

I'm using asp.net 2.0 and am trying to get one text box on the page, after
the user presses enter, to "click" a specific button. I copied the
javascript I used for a .net 1.1 web app I did a while ago but it doesn't
appear to work with .net 2.0? Below is my script. Any ideas?

<script language="javascript">

function clickButton(e, buttonid){

var bt = document.getElementById(buttonid);

if (typeof bt == 'object'){

if(navigator.appName.indexOf("Netscape")>(-1)){

if (e.keyCode == 13){

bt.click();

return false;

}

}

if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){

if (event.keyCode == 13){

bt.click();

return false;

}

}

}

}

</script>

in the textbox

onkeydown="javascript: return
clickButton(event,'_ctl0_uscTopBag_btnSearch');"

The event fires to the line of bt.click() but it doesn't appear to click it.
The ID for the button I am sending is what the ID of the button is after the
page renders, which javascript likes. Any ideas?

Thanks!!

David Lozzi
Oct 25 '06 #1
3 2366
in asp.net 2.0, panel's have a defaultButton property which does what you
want.

You can see an example at:
http://weblogs.asp.net/scottgu/archi...04/421647.aspx

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"David Lozzi" <dl****@nospam.nospamwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Howdy,

I'm using asp.net 2.0 and am trying to get one text box on the page, after
the user presses enter, to "click" a specific button. I copied the
javascript I used for a .net 1.1 web app I did a while ago but it doesn't
appear to work with .net 2.0? Below is my script. Any ideas?

<script language="javascript">

function clickButton(e, buttonid){

var bt = document.getElementById(buttonid);

if (typeof bt == 'object'){

if(navigator.appName.indexOf("Netscape")>(-1)){

if (e.keyCode == 13){

bt.click();

return false;

}

}

if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){

if (event.keyCode == 13){

bt.click();

return false;

}

}

}

}

</script>

in the textbox

onkeydown="javascript: return
clickButton(event,'_ctl0_uscTopBag_btnSearch');"

The event fires to the line of bt.click() but it doesn't appear to click
it. The ID for the button I am sending is what the ID of the button is
after the page renders, which javascript likes. Any ideas?

Thanks!!

David Lozzi


Oct 25 '06 #2
But I have only one Form for the page and two or three submit buttons, for
example

Top of page is search site textbox with a button
Middle of page is signup for new account, multiple fields and a submit
button
Right of page is a login box with username and password with a submit
button.

The signup for new account is fired when enter is pressed in any of the
sections, which makes sense. How do I specify where to submit to?

Thanks

David Lozzi
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:%2******************@TK2MSFTNGP02.phx.gbl...
in asp.net 2.0, panel's have a defaultButton property which does what you
want.

You can see an example at:
http://weblogs.asp.net/scottgu/archi...04/421647.aspx

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"David Lozzi" <dl****@nospam.nospamwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>Howdy,

I'm using asp.net 2.0 and am trying to get one text box on the page,
after the user presses enter, to "click" a specific button. I copied the
javascript I used for a .net 1.1 web app I did a while ago but it doesn't
appear to work with .net 2.0? Below is my script. Any ideas?

<script language="javascript">

function clickButton(e, buttonid){

var bt = document.getElementById(buttonid);

if (typeof bt == 'object'){

if(navigator.appName.indexOf("Netscape")>(-1)){

if (e.keyCode == 13){

bt.click();

return false;

}

}

if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){

if (event.keyCode == 13){

bt.click();

return false;

}

}

}

}

</script>

in the textbox

onkeydown="javascript: return
clickButton(event,'_ctl0_uscTopBag_btnSearch'); "

The event fires to the line of bt.click() but it doesn't appear to click
it. The ID for the button I am sending is what the ID of the button is
after the page renders, which javascript likes. Any ideas?

Thanks!!

David Lozzi



Oct 25 '06 #3
wrap the textboxes in a <asp:panel and specify it's defaultButton.

I think you are thinking about the defaultButton for the form...but you can
specify it at the panel level...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"David Lozzi" <dl****@nospam.nospamwrote in message
news:ui****************@TK2MSFTNGP04.phx.gbl...
But I have only one Form for the page and two or three submit buttons, for
example

Top of page is search site textbox with a button
Middle of page is signup for new account, multiple fields and a submit
button
Right of page is a login box with username and password with a submit
button.

The signup for new account is fired when enter is pressed in any of the
sections, which makes sense. How do I specify where to submit to?

Thanks

David Lozzi
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:%2******************@TK2MSFTNGP02.phx.gbl...
>in asp.net 2.0, panel's have a defaultButton property which does what you
want.

You can see an example at:
http://weblogs.asp.net/scottgu/archi...04/421647.aspx

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"David Lozzi" <dl****@nospam.nospamwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl. ..
>>Howdy,

I'm using asp.net 2.0 and am trying to get one text box on the page,
after the user presses enter, to "click" a specific button. I copied the
javascript I used for a .net 1.1 web app I did a while ago but it
doesn't appear to work with .net 2.0? Below is my script. Any ideas?

<script language="javascript">

function clickButton(e, buttonid){

var bt = document.getElementById(buttonid);

if (typeof bt == 'object'){

if(navigator.appName.indexOf("Netscape")>(-1)){

if (e.keyCode == 13){

bt.click();

return false;

}

}

if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){

if (event.keyCode == 13){

bt.click();

return false;

}

}

}

}

</script>

in the textbox

onkeydown="javascript: return
clickButton(event,'_ctl0_uscTopBag_btnSearch') ;"

The event fires to the line of bt.click() but it doesn't appear to click
it. The ID for the button I am sending is what the ID of the button is
after the page renders, which javascript likes. Any ideas?

Thanks!!

David Lozzi




Oct 25 '06 #4

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

Similar topics

7
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
1
by: Andrea Williams | last post by:
I've created a simple search form and a submit button. On click of the button, I have code-behind that runs and fills a datagrid. However, it the person is focused on one of the other controls...
5
by: Eric | last post by:
Hi All, I'm very experienced in traditional ASP and am new to (am learning) ASP.NET. FYI: I am initially learning ASP.NET with VB.NET to ease the transition for me. I have encountered what I...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
5
by: csgraham74 | last post by:
Hi there, I have just written an applcation in asp.net. In testing i have found that the enter key press on a button does not fire a javascript confirm prompt. is there anyway i can get this...
4
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
2
by: arpitwcc | last post by:
i am making u user login page where there are few buttons at the top of the page like Home, Services, About Us etc and below it i hav Username -- textbox Password --textbox Login --image...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.