asp.net - Problem with textbox inside updatepanel - not causing OnTextChanged event -
I have the following condition: I have a textbox inside AJAX updatepanel, wherever the user type in the reader to display a message to me (Different message depending on user typed data)
& lt; Asp: UpdatePanel ID = "Update Panel 1" runat = "server" updatemod = "always" & gt; & Lt; ContentTemplate & gt; & Lt; Asp: text box id = "txtMyTexbox" runat = "server" width = "500px" OnTextChanged = "txtMyTexbox_TextChanged" autoptback = "true" & gt; & Lt; / Asp: Textbox & gt; & Lt; Br / & gt; & Lt; Asp: label id = "lblMessage" runat = "server" CssClass = "errorMessage" visible = "false" & gt; Hello World & lt; / Asp: Label & gt; & Lt; / ContentTemplate & gt; & Lt; Trigger & gt; & Lt; Asp: AsyncPostBackTrigger ControlID = "txtMyTexbox" /> & Lt; / Trigger & gt; & Lt; / ASP: UpdatePanel & gt; On the server side I have written the following on the page load
ScriptManager.GetCurrent (this). Registration AsynxPostback Control (txtMyTexbox); and such a method
secure void txtMyTexbox_TextChanged (object sender, EventArgs e) {if (.....) {lblMessage.Visible = false; } And {lblMessage.Visible = true; }} My problem now is that: When the user types in the text box, then this is not the reason for an ontaked change event.
Am I missing something?
I'm not sure about the UpdatePanel in your problem.
Actually, text-marked event is not caused by the fire while typing . This will focus only after , the text box loses focus if AutoPostback is set to True , or when the next postback occurs , Then it is straightforward. Please see the docs for more.
Afack, your best bet is probably to handle the funnel event in javascript.
Here is an example of a simple jQuery:
$ (document) .ready (function () {$ (': text [id $ = yourTextBox]'). Keyup (function () (if ($ (this) .val () === "Your CSS ('Visibility', 'View');} and {$ ('Span [ID $ = Your Label]'). ('Visibility', 'hidden');}});});
Comments
Post a Comment