asp.net c#中针对不同按钮的不同文本区控件
本文关键字:按钮 文本区 控件 net asp | 更新日期: 2023-09-27 18:18:47
最近我在Visual Studio 2012中使用asp.net为我的学校项目制作一个网页。现在我想针对不同的按钮单击事件打开两个不同的文本区域。我的意思是,假设有两个按钮;"添加",'View'和两个文本区。当页面被加载时,Textarea1将被显示,Textarea2将被隐藏。当我点击View按钮时,它将显示Textarea2并隐藏Textarea1 ,而无需重新加载页面。以及当我点击添加按钮时,它将显示Textarea1和隐藏Textarea2 而无需重新加载页面。我该怎么做呢?请帮助! !
我希望这将帮助您!!!!
<asp:TextBox id="TextArea1" TextMode="multiline" Columns="50"Rows="5"runat="server" />
<asp:TextBox id="TextArea2" TextMode="multiline" Columns="50" Rows="5" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Add" OnClick="Button1_Click" Font-Bold="true" ForeColor="DodgerBlue"Height="45" Width="150"/>
<asp:Button ID="Button2" runat="server" Text="view" OnClick="Button2_Click" Font-Bold="true" ForeColor="DodgerBlue"Height="45" Width="150"/>
protected void Page_Load(object sender, EventArgs e)
{
TextArea1 .Visible = true;
TextArea2 .Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextArea1 .Visible = false;
TextArea2 .Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextArea1 .Visible = true;
TextArea2 .Visible = false;
}