At 11:54 01-05-2002 -0700, you wrote:
>The nature of ASP.Net controls is to generate a postback when the return key
>is pressed. You might want to
>simply suppress this action using client-side JavaScript to check for the
>return key. The following code will
>accomplish this for you:

Does this work with Netscape 4.08+?

Anyway, I do think doing this is bad, usability-wise, and I
can't really believe there's no way of ca_t_ching this event
on the server. Usually the sequence is PageOnLoad -> Other Events -> PreRender.
When I simply press return on the form, what seems to be happening is just
PageLoad -> PreRender.

Is there an event I don't know of where I can update the griddata, etc.?

I can always try to do a trick, but it's a ugly workaround and
I'm not sure it would work:

- create a simple flag bEventHandled valued False.

- On _ALL_ of my OnClick event handlers, set the flag to True.

- On the OnPrender Event Handler, if the Flag is false and this is
   a postback, do the databind/grid update (that is: if no event handler
   was called, do the bind now).

- Set it to False again in the last line of the OnPreRender Event Handler.

Any alternatives? Can't really believe MS didn't think of this.

joćo martins


><!-- Begin
>function onKeyPress () {
>var e = window.event;
>if(e.srcElement && e.srcElement.rows && e.srcElement.cols)
>         // textarea e.g multiline textbox
>         return true;
>return (e.keyCode != 13);
>
>}
>document.onkeypress = onKeyPress;
>  End -->
>
>Richard Spence
>mailto:[EMAIL PROTECTED]
>
>
>-----Original Message-----
>From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
>Joćo Pedro Martins
>Sent: Tuesday, April 30, 2002 6:28 PM
>To: [EMAIL PROTECTED]
>Subject: Re: [DOTNET] Submit by pressing Return - event?
>
>
>At 12:46 01-05-2002 +1200, you wrote:
> >Sounds like your datagrid has ViewState disabled, or you are DataBinding
> >on every postback in your Page_Load method.
>
>True, False.
>
>Is there any server-side event I can catch when the user
>simply submits the form in a situation like the one I
>described? (basically, imagine an input field with a
>submit button that is an image and NOT a "regular"
>Button). The onclick@server is not ran.
>
>The Grid is being binded to a SqlDataReader, not a DataSet,
>so I have to rebind when the user navigates in the pages.
>
>j
>
>
>
> >Kirk
> >
> >-----Original Message-----
> >From: Joćo Pedro Martins [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, 1 May 2002 7:13 a.m.
> >To: [EMAIL PROTECTED]
> >Subject: [DOTNET] Submit by pressing Return - event?
> >
> >
> >Hello,
> >
> >question:
> >
> >I have a normal runat=server form. In it I have
> >some input fields to specify search criteria,
> >a ImageButton that starts the search (with a server-side onclick event
> >handler), and below it a data grid with the results. By default, this data
> >grid is loaded with N of the most recent items of a sql table.
> >
> >In the page there are also 2 datagrid paging buttons,
> >previous and next, each with a custom event handler.
> >These are regular LinkButtons.
> >
> >My problem is simple, and is present as well in, for
> >example, the QuickStart Samples: *everything* works
> >fine if I mouse click the ImageButton or navigate with
> >the pager links: the data grid is updated, the input
> >fields keep their values, etc.
> >
> >*IF*, however, I set the cursor focus on one of the
> >input fields, and just press Return on the keyboard,
> >the page reloads, the input fields lose their values,
> >and the datagrid is empty.
> >
> >This happens because I am not "trapping" the "Submit"
> >event, if there is one, so I don't DataBind and the
> >data grid shows up empty. (I miss simple ASPs, sometimes)
> >
> >Is there a way to prevent this?
> >
> >I tried creating a server-side custom validator,
> >but no luck: it wasn't called.
> >
> >
> >I looked at some examples that work, but these use
> >Button's that are selected by default. Most don't work,
> >like I said, even in the QuickStart tutorials.
> >
> >
> >Any help would be appreciated,
> >j
> >--
> >Joćo Pedro Martins
> >[EMAIL PROTECTED]
> >|create|it|
> >http://www.create.pt
> >http://www.usabilidade.com
> >
> >You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> >subscribe to other DevelopMentor lists at http://discuss.develop.com.
> >
> >You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> >subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to