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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
bruceshiningAuthor Commented:
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.
I've found a workaround for you that should do the trick:
1) You have two events: TextBox1_TextChanged, Button1_Click.
2) add a hidden button which does nothing:
<?xml:namespace prefix = asp />
3) add this simple javascript:

It would do a delay when leaving the textbox.
4) then just use the following on the design:

As you can see the button raises it's event. And the textbox raises it's event only that on blur (when tabbing out of it) it should wait a very short time before it would raise the text_changed event this would give time for the click event to be raised if clicked straight from the textbox without killing the click event first.

Try that, I did and it should work for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

bruceshiningAuthor Commented:
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.
bruceshiningAuthor Commented:
I simplified the solution by NOT adding a button and instead changed the javascript to:
<SCRIPT  type=text/javascript>
       function Func1()
... to just submit the page which does same thing... and still works!
bruceshiningAuthor Commented:
I have been testing with FireFox and it works great!
However with IE 6 & IE 7 it does not seem to be working.


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???
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.