I change my Textbox.Text property using JavaScript Code.
Ususally the TextBox_TextChanged Event will fire after loosing focus on the Control, so if I manually type some text into the textbox and setting the focus on another Control by clicking on it the Event fires successfully. As it seems the Focus wont change
when I manipulate the TextBox.Text Property using JavaScript which brings me to my actual question:
How can I force firing the TextBox_TextChanged Event in JavaScript?
<script type="text/javascript" charset="utf-8">
$(function () {
// populate User Array
var arruser = new Array();
var listbox = document.getElementById('<%=lbxUser.ClientID%>');
for (var count = 0; count < listbox.options.length; count++) {
arruser[count] = listbox.options[count].text;
}
//-------------------------------
// Single field
//-------------------------------
$('#singleFieldTags').tagit({
availableTags: arruser,
allowSpaces: true,
// This will make Tag-it submit a single form value, as a semicolon-delimited field.
singleField: true,
// original: singleFieldNode: $('#txtUserList')
singleFieldNode: $('*[id$="txtUserList"]')
});
});
</script>
ronin47
Member
62 Points
73 Posts
server side ASP.NET TextBox_TextChanged Event won't fire after TextBox.Text Property was changed ...
May 01, 2012 08:29 AM|LINK
Hey guys,
I change my Textbox.Text property using JavaScript Code.
Ususally the TextBox_TextChanged Event will fire after loosing focus on the Control, so if I manually type some text into the textbox and setting the focus on another Control by clicking on it the Event fires successfully. As it seems the Focus wont change when I manipulate the TextBox.Text Property using JavaScript which brings me to my actual question:
How can I force firing the TextBox_TextChanged Event in JavaScript?
My Code (2nd part is JQuery/JavaScript):
<asp:TextBox ID="txtUserList" class="div2ndRow" runat="server" Width="250px" style="/*display:none*/" AutoPostBack="true" CausesValidation="True"></asp:TextBox><script type="text/javascript" charset="utf-8"> $(function () { // populate User Array var arruser = new Array(); var listbox = document.getElementById('<%=lbxUser.ClientID%>'); for (var count = 0; count < listbox.options.length; count++) { arruser[count] = listbox.options[count].text; } //------------------------------- // Single field //------------------------------- $('#singleFieldTags').tagit({ availableTags: arruser, allowSpaces: true, // This will make Tag-it submit a single form value, as a semicolon-delimited field. singleField: true, // original: singleFieldNode: $('#txtUserList') singleFieldNode: $('*[id$="txtUserList"]') }); }); </script>