Fill Textbox from other textboxes without post back and without AJAX in ASP.NET 2.0

Some times we need to concat some fields on runtime without postback like Address-City-State or do some calculation which depends on other user input.
Here is sample example In which we will fill textbox txt3 using txt1 and txt2

<script type="text/javascript" >
function AutoFill()
{
var src1 = document.getElementById('<%=txt1.ClientID%>').value;
var src2 = document.getElementById('<%=txt2.ClientID%>').value;
document.getElementById('<%=txt3.ClientID%>').value = src1+' '+src2;
}
</script>
<asp:TextBox ID="txt1" runat="server" onchange="AutoFill()"></asp:TextBox><br />
<asp:TextBox ID="txt2" runat="server" onchange="AutoFill()"></asp:TextBox>
<asp:TextBox ID="txt3" runat="server"></asp:TextBox>

No comments:

Post a Comment