views:

356

answers:

2

I have textboxes being generated by a repeater that use OnTextChanged with autopostback enabled so that I can know when when the values change. This all works perfect.

The problem starts when I try to click on any buttons on the page. The loss of focus triggers the event for the OnTextChanged; however, the event for my buttons never get fired.

I checked this in the debugger and while debugging if I put a break-point in the page_load it will call both; however, without the break-point it still only calls the OnTextChanged event.

I found this post on JavaScript. If my problem is also JavaScript related, why does the clicking of the button fire in debug mode?

Thanks.

A: 

Rethink what it is you are trying to do. You should, first of all, not be enabling autopostback. You should be capturing the onBlur event and capturing it from javascript. Have your javascript code do whatever it is your trying to do.

icemanind
A: 

I have the same issue,

I have created a simple web form, containing one text box and one button. I have captured the onblur event of the text box.

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Untitled Page</title> 
    <script language="javascript" type="text/javascript"> 
    function onTextBoxBlur() 
    { 
        alert("On blur"); 
        return true; 
    } 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <asp:TextBox ID="TextBox1" runat="server" onblur="onTextBoxBlur();"></asp:TextBox> 
    <asp:Button ID="Button1" runat="server" Text="Button" /> 
</form> 
</body> 
</html> 

When I click on the button then, the onblur event of textbox occurs but the onclick of the button doesn't. And when I remove the alert box from the js function then it works fine. I think it is due to the alert box. Any idea why is this so?

Vinod T. Patil