To implement this functionality, use the following HTML markup:
<div style="border:solid 1px black;width:220px;padding:5px;float:left" >
<asp:Label ID="Label1" runat="server" Text=""
></asp:Label>
</div>
<div style="float:left;margin-top:-8px">
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="Content/swap2.png"
OnClick="ImageButton1_Click"
/>
</div>
<div style="border:solid 1px black;width:220px;padding:5px;float:left" >
<asp:Label ID="Label2" runat="server" Text="xx"
></asp:Label>
</div>
The code behind for swapping values on button click is as follows:
Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs)
Dim strTemp As String = Label1.Text
Label1.Text = Label2.Text
Label2.Text = strTemp
End Sub
Visual representation of the result can be seen here.
Although the example uses labels, text boxes can also be used interchangeably for this functionality.