[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1965
  • Last Modified:

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.
0
bruceshining
Asked:
bruceshining
1 Solution
 
rajeeshmcaCommented:
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
             }
    }
0
 
bruceshiningAuthor Commented:
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.
0
 
sagirCommented:
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.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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.
0
 
bruceshiningAuthor Commented:
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!
0
 
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.

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???
0
 
anixon93Commented:
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.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now