Reputation: 247
I have a GridView and a TextBox in one of its fields:
<asp:GridView ID="NTSBulkEditGridView" runat="server" AutoGenerateColumns="false" AllowSorting="true" Height="500px"
DataKeyNames="BookStem" OnRowDataBound="NTSBulkEditGridView_RowDataBound" DataSourceID="NTSSqlDataSource">
<Columns>
<asp:TemplateField HeaderText="Priority" SortExpression="Priority">
<ItemTemplate>
<asp:TextBox ID="txtPriority" runat="server" Text='<%# Eval("Priority") %>' BorderStyle="None" Width="80%" OnTextChanged="TextBox_Changed" AutoPostBack="true"></asp:TextBox>
<asp:CompareValidator ID="PriorityCompareValidator" runat="server" ControlToValidate="txtPriority" Display="Dynamic" ErrorMessage="Priority must be an integer!" Text="*" Operator="DataTypeCheck" Type="Integer" ValidationGroup="InsertUpdateNewTitlesStatusValidation" ></asp:CompareValidator>
</ItemTemplate>
</asp:TemplateField>
...
Could you please tell me why TextBox_Changed() is never called when I change text and press Enter? I tried to put same kind of a TextBox outside of the GridView, and there it works. Thanks.
Upvotes: 0
Views: 1954
Reputation: 35822
TextChanged of an ASP.NET TextBox translates into blur
JavaScript event. And blur
occurs when the text of the input element is changed and the input element loses focus. Try to change the text, but don't hit Enter. Simply hit TAB
key to go to next field. Does it fire post back?
Update:
Well, I saw that link. Two things. First, if you notice, it goes back to 2005 and ASP.NET 2.0 and we all know that 6 years in the world of computer means 60 years. So that article is obsolete by now. Second, sometimes a pattern only exists in articles, and you rarely see it in real productive systems. How many bulk actions have you seen on the web? And what type do they have? Consider Gmail, or Yahoo mail for example. You can mark 20 or 30 or X number of emails as read in one shot. But, can you respond to 20 mails in one step? Nope, just because it doesn't make sense. I've never seen a bulk action on a text box in web world. I think you'd better stick to use AJAX, with better performance, and more user acceptance. :)
Upvotes: 1