【发布时间】:2014-12-29 12:29:57
【问题描述】:
我有一个C# ASP .net 网络表单,其中一个面板具有许多控件,例如文本框和表格列中的下拉菜单。允许用户在这些控件中输入数据,当按下复制按钮时,该面板的所有内容应复制到同一页面上的另一个面板,该面板具有完全相同的控件和列,其启用属性设置为 false
我只能选择像下面那样做
例如:-
Protected void Button_click ()
{
Panel2.textbox1.Text = Panel1.textbox1.Text;
Panel2.textbox2.Text = Panel1.textbox2.Text;
...
...
...
Panel2.textbox30.Text = Panel1.textbox30.Text;
这会导致很多代码行,我觉得这不是好方法。您能否提出任何其他替代方案,或者这是唯一的方法?
我的标记看起来像这样
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="AjaxToolkitTrial.WebForm5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>
<asp:Panel ID="Panel1" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Copy" />
</td>
</tr>
</table>
</asp:Panel>
</td>
<td>
<asp:Panel ID="Panel2" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
提前谢谢..
【问题讨论】: