Link to home
Start Free TrialLog in
Avatar of bruceshining
bruceshiningFlag for United States of America

asked on

TextBox onTextChanged with AutoPostBack=true "hides" onClick of other buttons on the page.

There is a related question>> ID: 25272373  that provides an answer...
  except in that case the button that should be clicked is known.

My UI has a repeater and each repeater "row" has a single textbox and two buttons.
I cannot manually fire the click event on THE button, because there are two buttons and I would have to know which one got clicked.

I am working on some javascript to handle the onChanged event on the Client side, but wonder if anyone knows how to handle the situation I have described.
Avatar of rajeeshmca
rajeeshmca
Flag of India image

Hi bruceshining,

There is an event called OnItemCommand for the repeater...

This gets triggered whenever a command event happens... U can use the CommandName property to handle ur situation...

To differentiate between the buttons u can do the following:
 Add CommandName Property for the buttons like

<asp:Button id="Button1" Text="First Button" runat="Server" CommandName="FirstBtn" />
<asp:Button id="Button2" Text="Second Button" runat="Server" CommandName="SecBtn" />

In the OnItemCommand Event u can do the following:

protected void rptrExample_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
             if(e.CommandName == "FirstBtn")
             {
                      // button1 click functionality here
             }
             else   if(e.CommandName == "SecBtn")
             {
                      // button2 click functionality here
             }
    }
Avatar of bruceshining

ASKER

rajeeshmca:
That is how I am already doing it.
When a user clicks on the Button (in a repeater row), the onchanged event fires for the (just-changed by user) textBox is the same row...
but the button action never happens...
The event never gets fired.  Only the textBox onChanged event is processed.
I actually have two buttons providing separate action on each repeater row and regardless of which one I click, the associated event does not fire (if I had changed the textbox).  If the textbox has not been changed both buttons work as expected.  There is an "Accepted Solution" on the question that has been identified as related to this that I am going to try.
ASKER CERTIFIED SOLUTION
Avatar of sagir
sagir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did not notice that the autoPostBack had been removed.  Another user did notice and when I removed it, the solution worked fine.  The example was correct (no autoPostBack), but would have been better if description had said so.
Also,
I simplified the solution by NOT adding a button and instead changed the javascript to:
<SCRIPT  type=text/javascript>
       function Func1()
       {
           document.forms[0].submit();
       }
   </SCRIPT>
... to just submit the page which does same thing... and still works!
I have been testing with FireFox and it works great!
However with IE 6 & IE 7 it does not seem to be working.

Help!!

Does anyone think it makes a difference if the Javascript code finds a button and then invokes it;s click event OR the javascript just submits the form???
Avatar of anixon93
anixon93

for some reason the onblur event is no longer valid.  Is there another way to do this.  I'm having a similar issue.  I need the textchanged event to fire whether the button is clicked or not.  I also need the button to work the first time it is clicked wheather the textchanged event is fired or not.