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 n paste .asp files to Solution Explorer and have it show up there?

Hi,
I have just installed Visual Studio.net 2003 Enterprise Architect.
I have been using Visual Interdev so far, and I am used to be able to select
from a desktop, drag bunch of .asp files, and drop them into a Project
Explorer window and have it show there as a tree of files. Is there some
setting that I need to enable in Visual Studio.Net to do the drag and drop
to Solution Explorer (which seems to be the equivalent of Project Explorer
in InterDev) and have it show there as a tree of files?
Thank you for your help.Drop into the folder in Windows Explore, show all files and then include in
project is one option.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************************************************
Think outside the box!
*************************************************
"Jason Robertson" <jason6869@.msn.com> wrote in message
news:Y9udnQFGsI3wN-fcRVn-pA@.comcast.com...
> Hi,
> I have just installed Visual Studio.net 2003 Enterprise Architect.
> I have been using Visual Interdev so far, and I am used to be able to
> select
> from a desktop, drag bunch of .asp files, and drop them into a Project
> Explorer window and have it show there as a tree of files. Is there some
> setting that I need to enable in Visual Studio.Net to do the drag and drop
> to Solution Explorer (which seems to be the equivalent of Project Explorer
> in InterDev) and have it show there as a tree of files?
> Thank you for your help.
>

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