zoukankan
html css js c++ java
动态的控制Panel的显隐并控制其内容
1楼
Panel 控件是其他控件的容器。如果打算以编程方式生成多个控件或者打算隐藏/显示一组控件,此控件尤其有用。
下例说明如何使用 Panel 控件以编程方式生成控件和隐藏/显示一组控件。
<%@ Page Language="C#" %>
<html>
<head>
<script runat="server">
void Page_Load(Object sender, EventArgs e) {
// Show or hide the Panel contents.
if (Check1.Checked) {
Panel1.Visible=false;
}
else {
Panel1.Visible=true;
}
// Generate the Label controls.
int numlabels = Int32.Parse(DropDown1.SelectedItem.Value);
for (int i=1; i<=numlabels; i++) {
Label l = new Label();
l.Text = "Label" + (i).ToString();
l.ID = "Label" + (i).ToString();
Panel1.Controls.Add(l);
Panel1.Controls.Add(new LiteralControl("<br>"));
}
// Generate the Textbox controls.
int numtexts = Int32.Parse(DropDown2.SelectedItem.Value);
for (int i=1; i<=numtexts; i++) {
TextBox t = new TextBox();
t.Text = "TextBox" + (i).ToString();
t.ID = "TextBox" + (i).ToString();
Panel1.Controls.Add(t);
Panel1.Controls.Add(new LiteralControl("<br>"));
}
}
</script>
</head>
<body>
<h3>Panel Example</h3>
<form runat=server>
<asp:Panel id="Panel1" runat="server"
BackColor="gainsboro"
Height="200px"
Width="300px">
Panel1: Here is some static content...
<p>
</asp:Panel>
<p>
Generate Labels:
<asp:DropDownList id=DropDown1 runat="server">
<asp:ListItem Value="0">0</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>
<br>
Generate TextBoxes:
<asp:DropDownList id=DropDown2 runat="server">
<asp:ListItem Value="0">0</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>
<p>
<asp:CheckBox id="Check1" Text="Hide Panel" runat="server"/>
<p>
<asp:Button Text="Refresh Panel" runat="server"/>
</form>
</body>
</html>
查看全文
相关阅读:
linux下mysql定时备份数据库
怎么不让别人ping服务器
忘记了本地mysql密码应该怎么找回
配置 centos apache 的日志文件为每天保存,在home分区
Android 开发环境安装配置手册
jquery定时器
谷歌浏览器控制台出现 Unchecked runtime.lastError: The message port closed before a response was received. 的报错
百度文库下载文档没有下载劵解决
JRebel安装部署,激活
用Cygwin实现在window环境下使用Linux命令-nohup 来后台运行程序
原文地址:https://www.cnblogs.com/jxcia_Lai/p/1508916.html
最新文章
js获取url传递参数,js获取url?号后面的参数
手淘的flexible.js解决手机适配问题
用vue官方提供的模板vue-cli搭建一个helloWorld案例
富文本编辑器Quill的使用
jquery $(document).ready() 与window.onload的区别
移动端300ms点击延迟
node---解决MongoError: Authentication failed.----mongoose链接admin数据库成功,但是链接新建的数据库不成功!
js获取当前日期,并将其格式化为YYYY-MM-DD
java基础知识
18-跳转传递消息Intent
热门文章
17-生命周期Activity
16-输入框,文本编辑框EditText
vue-状态管理与Vuex
vue-监听视图滚动-加载下一页数据(鼠标滚动到底,加载)
15-下拉选择器Spinner
14-单选按钮RadioButton
sphinx 增量索引 实现近实时更新
PHP环境搭建
MySQL用户添加和分配权限
WinXP SSH连接不上虚拟机的解决方法
Copyright © 2011-2022 走看看