enter key hell problem 2

Discussion in 'ASP .Net' started by gh0st54, Sep 12, 2004.

  1. gh0st54

    gh0st54 Guest

    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 ???
    gh0st54, Sep 12, 2004
    #1
    1. Advertising

  2. Alvin Bruney [MVP], Sep 12, 2004
    #2
    1. Advertising

  3. 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/showdoc.asp?id=28&menuid=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/2004/06/asp200406so_f/asp200406so_f.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "gh0st54" <> wrote in message
    news:...
    > 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 ???
    Steve C. Orr [MVP, MCSD], Sep 12, 2004
    #3
  4. gh0st54

    Matt Berther Guest

    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 ???
    >
    Matt Berther, Sep 13, 2004
    #4
  5. gh0st54

    gh0st54 Guest

    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","javascript:SetTarget('submit');");
    this.txtSubject.Attributes.Add("onFocus","javascript:SetTarget('submit');");
    this.txtMessage.Attributes.Add("onFocus","javascript: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 ???
    > >
    gh0st54, Sep 15, 2004
    #5
  6. have you checked out Scott's blog here:
    http://www.hanselman.com/blog/PermaLink.aspx?guid=3f96f2ee-331f-480a-81af-dd62c8f92c23

    That covers a few of them.


    --
    Girish Bharadwaj
    http://msmvps.com/gbvb
    "gh0st54" <> wrote in message
    news:...
    > 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","javascript:SetTarget('submit');");
    >

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

    this.txtMessage.Attributes.Add("onFocus","javascript: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 ???
    > > >
    Girish bharadwaj, Sep 15, 2004
    #6
  7. gh0st54

    gh0st54 Guest

    does anyone at microsoft know what is the problem with my pages ?
    gh0st54, Sep 23, 2004
    #7
  8. gh0st54

    gh0st54 Guest

    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
    gh0st54, Sep 23, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gh0st54

    enter key hell problem 1

    gh0st54, Sep 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    452
    gh0st54
    Sep 13, 2004
  2. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    388
    Anders Matthiessen
    Jan 12, 2005
  3. M P
    Replies:
    1
    Views:
    463
  4. Matt
    Replies:
    1
    Views:
    503
    Michael Winter
    Mar 6, 2004
  5. HopfZ
    Replies:
    0
    Views:
    559
    HopfZ
    Aug 28, 2006
Loading...

Share This Page