postback problem

Discussion in 'ASP .Net' started by Alessandro, Oct 11, 2004.

  1. Alessandro

    Alessandro Guest

    Hi !

    I have a aspx page with these controls:

    1) a texbox to find person with a specific name....
    2) a button nto perform the search
    3) a datagrid tho show all user

    If i have the focus on the texbox and i click enter i have a
    postback.............. but i dont' want it, because the datagrid doesn't
    bind correctly... i must click on the button to do the postback......

    Any idea ?
     
    Alessandro, Oct 11, 2004
    #1
    1. Advertising

  2. The general cause here is the "default" button is fired, instead of the
    button you desire to be hit. For a simple form, try:

    Page.RegisterHiddenField( "__EVENTTARGET", "btnSearch" );

    Change btnSearch to your button name. That will fire the correct button for
    the form.

    If you need a particular button for different textboxes, you will have to
    move to JavaScript. Try this link for a C# method that writes out the
    JavaScript:

    http://dotnetjunkies.com/WebLog/darrell.norton/archive/2004/03/03/8374.aspx

    It is further culled here:

    http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20944907.html

    To disable the enter key, you have to trap that event in JavaScript. I would
    not head this direction unless absolutely necessary.


    ---

    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ***************************
    Think Outside the Box!
    ***************************


    "Alessandro" wrote:

    > Hi !
    >
    > I have a aspx page with these controls:
    >
    > 1) a texbox to find person with a specific name....
    > 2) a button nto perform the search
    > 3) a datagrid tho show all user
    >
    > If i have the focus on the texbox and i click enter i have a
    > postback.............. but i dont' want it, because the datagrid doesn't
    > bind correctly... i must click on the button to do the postback......
    >
    > Any idea ?
    >
    >
    >
     
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, Oct 11, 2004
    #2
    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. Psych971
    Replies:
    5
    Views:
    4,651
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?Q2hhZA==?=

    Postback not being set to True on first postback

    =?Utf-8?B?Q2hhZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    516
    =?Utf-8?B?Q2hhZA==?=
    Apr 4, 2005
  3. gce
    Replies:
    2
    Views:
    1,728
  4. Jacky Chau
    Replies:
    2
    Views:
    2,087
    Ninjamyst
    Jun 8, 2005
  5. Fabio Mastria
    Replies:
    5
    Views:
    4,380
    TechMCAD13
    Jan 30, 2008
Loading...

Share This Page