Transfer TextValue from one TextBox to another TextBox in ASP.NET

- Here we learn how to transfer one TextBox value to otherTextBox on Button Click Event.

First Take two TextBox and One Button Server Control on webform.

The Name assign on ID Property is TextBox1 = txtname , TextBox2 = txtanswer, Button1 = btnsubmit

Write below code in Body Tag :-

<body>
<form id=”form1″ runat=”server”>
<div>
<table border=”1″ bordercolor=”#000000″ style=”z-index: 100; left: 280px; position: absolute;
top: 40px”>
<tr>
<td colspan=”3″>
<asp:Image ID=”Image1″ runat=”server” ImageUrl=”~/img/newimg.png” /></td>
</tr>
<tr>
<td colspan=”3″ rowspan=”2″ style=”height: 21px; text-align: center”>
<table>
<tr>
<td style=”width: 100px”>
Enter Name :</td>
<td style=”width: 100px”>
<asp:TextBox ID=”txtname” runat=”server”></asp:TextBox></td>
<td style=”width: 100px”>
</td>
</tr>
<tr>
<td style=”width: 100px”>
</td>
<td style=”width: 100px”>
<asp:Button ID=”btnsubmit” runat=”server” OnClick=”btnsubmit_Click” Text=”Submit” /></td>
<td style=”width: 100px”>
</td>
</tr>
<tr>
<td style=”width: 100px”>
</td>
<td style=”width: 100px”>
<asp:TextBox ID=”txtanswer” runat=”server”></asp:TextBox></td>
<td style=”width: 100px”>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

</div>
</form>
</body>

TextBox control in ASP.Net

TextBox control in ASP.Net

Write below code in Button_Click Events:-

protected void btnsubmit_Click(object sender, EventArgs e)
{
txtanswer.Text = txtname.Text;
txtname.Text = “”;
}

TextBox control in ASP.Net

TextBox control in ASP.Net

- I hope you will enjoy this ASP.Net TextBox Example Tutorials.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 3 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">