You said As per my assumption due to autopostback if I write anything in the textbox a postback will occur.
That is wrong. It will fire text changed event when your focus from textbox will be out. So when you type something and press Tab key then only your TextChanged event will be triggered.
If you want to trigger TextChanged event when you type something then you should call it from javascript using OnKeyDown event. see below code sample :
<asp:TextBox ID="uname" runat="server" AutoPostBack="True"
OnKeyDown="TextChanged(this)" OnTextChanged="uname_TextChanged"></asp:TextBox>
<script type="text/javascript">
function TextChanged(control) {
$(control).change();
}
</script>
Now when you type anything in your textbox it will call TextChanged method of javascript and this method will trigger uname_TextChanged event.
Assumption:
If your textbox control is inside UpdatePanel then also your change event cannot be triggered. In such a case you should define trigger for text box. as mentioned below :
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<asp:TextBox ID="uname" runat="server" AutoPostBack="True"
OnKeyDown="TextChanged(this)" OnTextChanged="uname_TextChanged"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="uname" />
</Triggers>
</asp:UpdatePanel>
Q : which event will be triggered if autopostback occurs ?
Answer: Normally, for all the events for which contents are changed between the post server, AutoPostBack requires. But it wont be triggered until you define the event for that.
For example if you set the AutoPostBack property of the DropDownList to true, and if you don't specify the OnSelectedIndexChanged event then it will not trigger this event. But your page will be post back when you change the value.
Same thing happens in case of TextBox, CheckBox, RadioButton etc...
Hope it is enough to understand.
automatic postback to the server occurs when the TextBox control loses focus