Hi,
This behaviour is by design if form contains just one input. See
http://ppewww.ph.gla.ac.uk/~flavell/...mquestion.html
for more information.
Milosz Skalecki
MCP, MCAD
"peshrad" wrote:
> Hi !
>
> I'm working with Win 2K and Visual Studio 2003.
>
> I have a problem because pressing <ENTER> in a text input control causes a
> postback of my web form.
> Here comes some example code (already stripped of most of the unnecessary
> code):
>
> ----------------------------------------------------------------------------
> ----------------------------------------------------------
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" Content="C#">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body>
> <form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
> <input type="hidden" name="__VIEWSTATE"
> value="dDwtMTI3OTMzNDM4NDs7PmA5uGMyk9VLm/FRbF5zeYsdMA+5" />
>
> <INPUT onkeydown="alert('Hi, down !');" onkeyup="alert('Hi, up!');">
> </form>
> </body>
> </HTML>
> ----------------------------------------------------------------------------
> ----------------------------------------------------------
>
> The postback occurs after the onkeydown event and before the onkeyup event,
> but I don't understand why.
>
> Does anybody know a way of avoiding this undesirable automatic postback ?
>
> Your kind help would be appreciated.
>
> Peter
>
>
>