Monday, March 12, 2012

How to copy the content of a textbox with a button click?

Hi, i use Visual Web Developer 2005 express with Visual Basic and asp.net. I have a formView with a textbox and a button, i want to be able to copy the content of the textbox clicking on the button to paste the content in somewhere else.

Any one can help me with the code?

<asp:FormView ID="FormView1" runat="server" CellPadding="4" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="Both">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<ItemTemplate>
<table style="width: 561px; height: 85px" border="1" bordercolor="gainsboro">
<tr>
<td style="width: 156px; text-align: left;">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Small"
Text="Test:"></asp:Label></td>
<td style="width: 302px">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ed_order_number", "{0}") %>'
Width="250px"></asp:TextBox></td>
<td style="width: 54px; text-align: center;">
<asp:Button ID="Button1" runat="server" Text="Copy" OnClick="Button1_Click" /></td>
</tr>

</table>
</ItemTemplate>
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
<table style="width: 401px; height: 67px">
<tr>
<td colspan="3" rowspan="3" style="height: 34px">
<asp:Label ID="Label37" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Medium"
Text="Order Details"></asp:Label></td>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</HeaderTemplate>
</asp:FormView>

Are you looking for something like this?

protected void Button1_Click(object sender, EventArgs e){TextBox TextBox1 = FormView1.FindControl("TextBox1")as TextBox;if (TextBox1 ==null) {return; }string value = TextBox1.Text;// Do what you want with value here}

I need to simulate the Ctrl + C function on the button to copy the content of the textbox, and after paste it in somewhere else.


bonfa:

Hi, i use Visual Web Developer 2005 express with Visual Basic and asp.net. I have a formView with a textbox and a button, i want to be able to copy the content of the textbox clicking on the button to paste the content in somewhere else.

Any one can help me with the code?

Hi there,

Have a look at this forum with a working examplehttp://forums.asp.net/t/1047507.aspx


I use Visual basic not C Sharp.


The code is all Javascript thoughWink

Labels: , , , , , , , , , , , ,

how to Copy Item one Gridview to another gridview

I have Two gridview left side where i populate data from Database and other will be empty at 1st time my requirement is when click any item and click to add button it will remove from that cell and add in to second gridview

same thing happens through drag and drop system Drag from one gridview to another well but it will be helpfull how to remove and add one gridview to another can someone give me idea

bye take care
regards
vikrant

Check out these links

http://forums.asp.net/p/1169459/1955946.aspx

http://www.codeproject.com/KB/HTML/SelectMoveRowsFromTables.aspx

Labels: , , , , , , , , , ,