How to force a click on ASP.Net Button

Discussion in 'Javascript' started by BudhramM@gmail.com, Jun 6, 2006.

  1. Guest

    Hi,

    I have a webpage that has 2 ASP.Net buttons as well as some other
    controls. The controls are split up into two, there is a set of Combo
    boxes and then there is a single text input box. The controls are
    seperated by DIV's to create a TABView. So when clicking on the 1st tab
    will show the combo boxes and a button, the second tab will show a text
    box and a button.

    What I would like is for these buttons to be the default dependant on
    which tab was selected. I have managed to find what tab is clicked, but
    I need to know how I can set focus on a specified ASP.Net button.

    Any ideas. You can view the site: http://www.kitchensink.co.za.

    Thanx
     
    , Jun 6, 2006
    #1
    1. Advertising

  2. Guest

    Hi,

    here's how to "simulate" a button click:

    document.forms[0].MyButton.click();

    here's for example in an anchor tag:

    <a href="javascript:document.forms[0].MyButton.click();">simulate
    button click</a>

    Also you may use the onkeypress event for the textbox:

    <input type=text size=50 class="input_small" id=txtKeyword
    name=txtKeyword onkeypress="if(event.keyCode==13){
    doSearch(this.value); return false; }" >

    Another solution would be to disable the button on the first tab when
    the second one is active and vice versa.

    Hope this helps,
    Nikolay




    напиÑа:
    > Hi,
    >
    > I have a webpage that has 2 ASP.Net buttons as well as some other
    > controls. The controls are split up into two, there is a set of Combo
    > boxes and then there is a single text input box. The controls are
    > seperated by DIV's to create a TABView. So when clicking on the 1st tab
    > will show the combo boxes and a button, the second tab will show a text
    > box and a button.
    >
    > What I would like is for these buttons to be the default dependant on
    > which tab was selected. I have managed to find what tab is clicked, but
    > I need to know how I can set focus on a specified ASP.Net button.
    >
    > Any ideas. You can view the site: http://www.kitchensink.co.za.
    >
    > Thanx
     
    , Jun 6, 2006
    #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. Purvi T
    Replies:
    0
    Views:
    864
    Purvi T
    Oct 19, 2004
  2. Amelyan
    Replies:
    0
    Views:
    743
    Amelyan
    Jun 5, 2005
  3. Amelyan
    Replies:
    4
    Views:
    7,719
    sajidali3387
    Dec 9, 2011
  4. Amy
    Replies:
    0
    Views:
    997
  5. Amelyan

    Force Page_Load/PostBack on browser's back button click

    Amelyan, Jun 5, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    486
    Amelyan
    Jun 5, 2005
Loading...

Share This Page