473,412 Members | 2,293 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,412 software developers and data experts.

how to start sub from javascript?

Bob
Hi,

The user must enter a name into a text input control. Then i want to give
him the choice between clicking on the button with the mouse or pushing the
ENTER key of the keyboard.

This works when clicking on the button. My problem is that i don't know how
to start the sub 'pseudoserver' when pressing the ENTER key.

Here the code:

the aspx file:
------------
<input id="pseudo" type="text" onkeypress="pseudoclient(event)" />
<br />
<asp:Button ID="pseudoSubmit" runat="server" OnClick="pseudoserver" />

<script type="text/javascript">
function pseudoclient(touche)
{
var codetouche
touche=event
codetouche=touche.keyCode
if(codetouche == 13)
{
????
}
}
</script>

code-behind:
------------
Sub pseudoserver(ByVal sender As Object, ByVal e As System.EventArgs)
....
End sub

Thanks
Bob
Nov 11 '07 #1
3 1139
The Enter key will activate the default button on the form.
Normally, this is the first button on the form.

You can set another button as the default by setting the form's
DefaultButton property:

<form runat="server" DefaultButton="pseudoSubmit" >

Riki

Bob wrote:
Hi,

The user must enter a name into a text input control. Then i want to
give him the choice between clicking on the button with the mouse or
pushing the ENTER key of the keyboard.

This works when clicking on the button. My problem is that i don't
know how to start the sub 'pseudoserver' when pressing the ENTER key.

Here the code:

the aspx file:
------------
<input id="pseudo" type="text" onkeypress="pseudoclient(event)" />
<br />
<asp:Button ID="pseudoSubmit" runat="server" OnClick="pseudoserver" />

<script type="text/javascript">
function pseudoclient(touche)
{
var codetouche
touche=event
codetouche=touche.keyCode
if(codetouche == 13)
{
????
}
}
</script>

code-behind:
------------
Sub pseudoserver(ByVal sender As Object, ByVal e As System.EventArgs)
...
End sub

Thanks
Bob
--
Riki
Nov 11 '07 #2
Bob
Thanks, but unfortunately, this page is a content page linked to a
masterpage. And there is no <formin it.
"Riki" <ri**@dontnagme.comschreef in bericht
news:O3**************@TK2MSFTNGP06.phx.gbl...
The Enter key will activate the default button on the form.
Normally, this is the first button on the form.

You can set another button as the default by setting the form's
DefaultButton property:

<form runat="server" DefaultButton="pseudoSubmit" >

Riki

Bob wrote:
>Hi,

The user must enter a name into a text input control. Then i want to
give him the choice between clicking on the button with the mouse or
pushing the ENTER key of the keyboard.

This works when clicking on the button. My problem is that i don't
know how to start the sub 'pseudoserver' when pressing the ENTER key.

Here the code:

the aspx file:
------------
<input id="pseudo" type="text" onkeypress="pseudoclient(event)" />
<br />
<asp:Button ID="pseudoSubmit" runat="server" OnClick="pseudoserver" />

<script type="text/javascript">
function pseudoclient(touche)
{
var codetouche
touche=event
codetouche=touche.keyCode
if(codetouche == 13)
{
????
}
}
</script>

code-behind:
------------
Sub pseudoserver(ByVal sender As Object, ByVal e As System.EventArgs)
...
End sub

Thanks
Bob

--
Riki

Nov 11 '07 #3
Hi, Bob

I think you can do it through client script.

---- BEGIN CODE ----
<script type='text/javascript'>
function TextBox_onKeyPress(e, obj)
{
e = e ? e : window.event;
if (e.keyCode != 13)
return;

var oForm = obj;
while (oForm && oForm.tagName != "FORM")
oForm = oForm.parentNode;

if (oForm)
oForm.submit();
}
</script>
....
<input type='text' onkeypress='TextBox_onKeyPress(event, this)' />
---- END CODE ----

Regards,

Paulo Santos
http://pjondevelopment.50webs.com
On Nov 11, 2:43 pm, "Bob" <b...@no.erwrote:
Thanks, but unfortunately, this page is a content page linked to a
masterpage. And there is no <formin it.

"Riki" <r...@dontnagme.comschreef in berichtnews:O3**************@TK2MSFTNGP06.phx.gbl. ..
The Enter key will activate the default button on the form.
Normally, this is the first button on the form.
You can set another button as the default by setting the form's
DefaultButton property:
<form runat="server" DefaultButton="pseudoSubmit" >
Riki
Bob wrote:
Hi,
The user must enter a name into a text input control. Then i want to
give him the choice between clicking on the button with the mouse or
pushing the ENTER key of the keyboard.
This works when clicking on the button. My problem is that i don't
know how to start the sub 'pseudoserver' when pressing the ENTER key.
Here the code:
the aspx file:
------------
<input id="pseudo" type="text" onkeypress="pseudoclient(event)" />
<br />
<asp:Button ID="pseudoSubmit" runat="server" OnClick="pseudoserver" />
<script type="text/javascript">
function pseudoclient(touche)
{
var codetouche
touche=event
codetouche=touche.keyCode
if(codetouche == 13)
{
????
}
}
</script>
code-behind:
------------
Sub pseudoserver(ByVal sender As Object, ByVal e As System.EventArgs)
...
End sub
Thanks
Bob
--
Riki- Hide quoted text -

- Show quoted text -

Nov 11 '07 #4

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

Similar topics

6
by: Dropstengel | last post by:
Hi, Although I'm very familair with C++ programming, I'm having some problems coding up a piece of JavaScript for my sister in law. The problem is the following: From a website I need to...
31
by: Prabhat | last post by:
Hi All, The "Session_OnStart" event doesnot fire if the website has .htm file as the startup document. If I change the extension of the default document from ..htm to .asp then I can see the...
2
by: | last post by:
Hi, I'm using VS .NET 2003 edition and I had built a web project and I had been using it. But I changed a few settings(why did I ever do that...:( ) Now I'm unable to run my Web application...
2
by: Jan Paul van de Berg | last post by:
I have a piece of software that people can download and a third party promoting that software. In order for them to be able to count the number of downloads, I have to put a tracking code on my...
8
praclarush
by: praclarush | last post by:
Ok, I'm new to JavaScript and I'm taking a class for it the assignment in it I'm supposed to create edit a pre-made page to display a marquee that automatically scrolls for the user, as well as give...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.