Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > enter key hell problem 2

Reply
Thread Tools

enter key hell problem 2

 
 
gh0st54
Guest
Posts: n/a
 
      09-12-2004
Hi me again

problem 2

on pages that have no user controls i want to submit using the enter key

i register
Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");

when i press enter it doesn't fire

what am i missing ???
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      09-12-2004
start here
http://www.allasp.net/enterkey.aspx

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"gh0st54" <> wrote in message
news: om...
> Hi me again
>
> problem 2
>
> on pages that have no user controls i want to submit using the enter key
>
> i register
> Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");
>
> when i press enter it doesn't fire
>
> what am i missing ???



 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      09-12-2004
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here's 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


"gh0st54" <> wrote in message
news: om...
> Hi me again
>
> problem 2
>
> on pages that have no user controls i want to submit using the enter key
>
> i register
> Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");
>
> when i press enter it doesn't fire
>
> what am i missing ???



 
Reply With Quote
 
Matt Berther
Guest
Posts: n/a
 
      09-12-2004
Hello ,

I've had a post that discusses how to accomplish this on my website:

http://www.mattberther.com/2003/06/000125.html

--
Matt Berther
http://www.mattberther.com

> Hi me again
>
> problem 2
>
> on pages that have no user controls i want to submit using the enter
> key
>
> i register
> Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");
> when i press enter it doesn't fire
>
> what am i missing ???
>


 
Reply With Quote
 
gh0st54
Guest
Posts: n/a
 
      09-15-2004
Sorry
I tried it but doesn't work

i'm being sent back to index.aspx ??? weird

so what i do know is

if(!Page.IsPostBack)
{
bla bla bla .....
Page.RegisterHiddenField("__EVENTTARGET","submit" );

this.txtSendTo.Attributes.Add("onFocus","javascrip t:SetTarget('submit');");
this.txtSubject.Attributes.Add("onFocus","javascri pt:SetTarget('submit');");
this.txtMessage.Attributes.Add("onFocus","javascri pt:SetTarget('notsubmit');");
}

if(Page.IsPostBack){
if(Page.Request.Form["__EVENTTARGET"].ToString().ToLower()=="submit"){
this.Send();
}
}

I know it's ugly but it works.

there has to be something not that ugly


Matt Berther <> wrote in message news:<>...
> Hello ,
>
> I've had a post that discusses how to accomplish this on my website:
>
> http://www.mattberther.com/2003/06/000125.html
>
> --
> Matt Berther
> http://www.mattberther.com
>
> > Hi me again
> >
> > problem 2
> >
> > on pages that have no user controls i want to submit using the enter
> > key
> >
> > i register
> > Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");
> > when i press enter it doesn't fire
> >
> > what am i missing ???
> >

 
Reply With Quote
 
Girish bharadwaj
Guest
Posts: n/a
 
      09-15-2004
have you checked out Scott's blog here:
http://www.hanselman.com/blog/PermaL...f-dd62c8f92c23

That covers a few of them.


--
Girish Bharadwaj
http://msmvps.com/gbvb
"gh0st54" <> wrote in message
news: om...
> Sorry
> I tried it but doesn't work
>
> i'm being sent back to index.aspx ??? weird
>
> so what i do know is
>
> if(!Page.IsPostBack)
> {
> bla bla bla .....
> Page.RegisterHiddenField("__EVENTTARGET","submit" );
>
>

this.txtSendTo.Attributes.Add("onFocus","javascrip t:SetTarget('submit');");
>

this.txtSubject.Attributes.Add("onFocus","javascri pt:SetTarget('submit');");
>

this.txtMessage.Attributes.Add("onFocus","javascri pt:SetTarget('notsubmit');
");
> }
>
> if(Page.IsPostBack){
> if(Page.Request.Form["__EVENTTARGET"].ToString().ToLower()=="submit"){
> this.Send();
> }
> }
>
> I know it's ugly but it works.
>
> there has to be something not that ugly
>
>
> Matt Berther <> wrote in message

news:<>...
> > Hello ,
> >
> > I've had a post that discusses how to accomplish this on my website:
> >
> > http://www.mattberther.com/2003/06/000125.html
> >
> > --
> > Matt Berther
> > http://www.mattberther.com
> >
> > > Hi me again
> > >
> > > problem 2
> > >
> > > on pages that have no user controls i want to submit using the enter
> > > key
> > >
> > > i register
> > > Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");
> > > when i press enter it doesn't fire
> > >
> > > what am i missing ???
> > >



 
Reply With Quote
 
gh0st54
Guest
Posts: n/a
 
      09-23-2004
does anyone at microsoft know what is the problem with my pages ?
 
Reply With Quote
 
gh0st54
Guest
Posts: n/a
 
      09-23-2004
an other i noticed

i tried the following script :

function document.onkeydown(){
if(event.keycode==13){
event.returnvalue = false;
event.cancel=true;
//form.submit;
}
}

to block the postback to the page but it still posts back and i get
redirected to the index page

shouldn't this script prevent postback ??

thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
capturing from text area Shft+Enter, Control+Enter, Alt+Enter and browser issue. HopfZ Javascript 0 08-28-2006 10:11 AM
Enter Key H*ll, control enter key submit button BrianDH ASP .Net Web Controls 3 01-12-2005 08:29 PM
enter key hell problem 1 gh0st54 ASP .Net 2 09-13-2004 03:42 AM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
trigger HTML button by enter ENTER key Matt Javascript 1 03-06-2004 07:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57