<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="PanelDemo.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Panel Controls</h1>
<h2>Dynamically Generated Controls</h2>
<asp:Panel ID="pnlDynamic" runat="server" Height="150" Width="80%"
BackColor="Beige" Font-Names="Courier New"
HorizontalAlign="Center" Style="padding:20px" ScrollBars="Auto">
<br />This is panel setting
<p/> <p/>
</asp:Panel>
<table>
<tr>
<td>
Number of Labels:
</td>
<td>
<asp:DropDownList ID="ddlLabels" runat="server">
<asp:ListItem Text="0" Value="0"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Number of TextBoxs:
</td>
<td>
<asp:DropDownList ID="ddlBoxes" runat="server">
<asp:ListItem Text="0" Value="0"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
 
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkHide" runat="server" Text="Hide Panel"/>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Refresh Panel" />
</td>
</tr>
</table>
<hr />
<h2>ScrollBars and Wrapping</h2>
<asp:Panel ID="pnlScroll" runat="server" Height="200px"
Width="90%" GroupingText="ScrollBars & Wrap">
<asp:Label ID="lbPanelContent" runat="server" Text="Label"></asp:Label>
</asp:Panel>
<br />
<table>
<tr>
<td align="right">
ScrollBars:
</td>
<td>
<asp:DropDownList ID="ddlScrollBars" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="ddlScrollBars_SelectedIndexChanged">
<asp:ListItem Text="None" Selected="True"></asp:ListItem>
<asp:ListItem Text="Auto" ></asp:ListItem>
<asp:ListItem Text="Both" ></asp:ListItem>
<asp:ListItem Text="Horizontal" ></asp:ListItem>
<asp:ListItem Text="Vertical"></asp:ListItem>
</asp:DropDownList>
</td>
<td align="right" with="75">
Wrap:
</td>
<asp:RadioButtonList ID="rblWrap" runat="server"
AutoPostBack="true"
RepeatDirection="Horizontal" OnSelectedIndexChanged="rblWrap_SelectedIndexChanged">
<asp:ListItem Text="True" Value="true" Selected="True"></asp:ListItem>
<asp:ListItem Text="False" Value="false"></asp:ListItem>
</asp:RadioButtonList>
</tr> </table> </div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace PanelDemo
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (chkHide.Checked)
{
pnlDynamic.Visible = false;
}
else
{
pnlDynamic.Visible = true;
} int numlabels = Int32.Parse(ddlLabels.SelectedItem.Value); for (int i = 1; i < numlabels; i++)
{
Label lb1 = new Label();
lb1.Text = "Label " + (i).ToString();
pnlDynamic.Controls.Add(lb1);
pnlDynamic.Controls.Add(new LiteralControl("<br/>"));
} int numBoxes = Int32.Parse(ddlBoxes.SelectedItem.Value);
for (int i = 1; i < numBoxes; i++)
{
TextBox txt = new TextBox();
txt.Text = "TextBox " + i.ToString();
txt.ID = "TextBox " + i.ToString();
pnlDynamic.Controls.Add(txt);
pnlDynamic.Controls.Add(new LiteralControl("<br/>")); }
string strText = "填写长内容";
lbPanelContent.Text = strText;
} protected void ddlScrollBars_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
string strValue = ddl.SelectedValue; ScrollBars scrollBar = (ScrollBars)Enum.Parse(typeof(ScrollBars), strValue);
pnlScroll.ScrollBars = scrollBar;
} protected void rblWrap_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonList rbl = (RadioButtonList)sender;
pnlScroll.Wrap = Convert.ToBoolean(rbl.SelectedValue);
}
}
}

c#_DropdownList Panel Textbox 控件交互使用,有autopostback和没有的区别的更多相关文章

  1. ASP.Net TextBox控件只允许输入数字

    原文:ASP.Net TextBox控件只允许输入数字 1.1.在Asp.Net TextBox 控件的 OnKeyPress 事件中指定输入键盘码必须为数字: <asp:TextBox ID= ...

  2. JS与APP原生控件交互

    "热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显 ...

  3. 关于C#开发WEB项目TextBox控件的自适应高问题解决办法!

    前两天做WEB开发时候遇到了一个小问题TextBox 控件要根据输入的内容多少自动改变大小,并且这个大小要求是在本页面内最大化.也就是 Width="100%" Height=&q ...

  4. [转载]ASP.NET中TextBox控件设立ReadOnly="true"后台取不到值

    原文地址:http://www.cnblogs.com/yxyht/archive/2013/03/02/2939883.html ASP.NET中TextBox控件设置ReadOnly=" ...

  5. 设置TextBox控件的TextMode属性

    我想在程式代碼中將TextBox控件的TextMode属性设置為Password,寫成TextBox1.TextMode=MultiLine和TextBox1.TextMode="Multi ...

  6. 验证标题是否存在(TextBox控件失去焦点验证)

    首先解释两个属性, AutoPostBack 属性用于设置或返回当用户在 TextBox 控件中按 Enter 或 Tab 键时,是否发生自动回传到服务器的操作. 如果把该属性设置为 TRUE,则启用 ...

  7. 关于ASP.net TextBox控件的失去焦点后触发其它事件

    编写人:CC阿爸 2015-2-02 今天在这里,我想与大家一起分享如何处理的ASP.net TextBox控件的失去焦点后触发其它事件的问题,在此做个小结,以供参考.有兴趣的同学,可以一同探讨与学习 ...

  8. C# Windows - TextBox 控件

    .NET Framework内置了两个基本控件来提取用户输入的文本: TextBox和RichTextBox.这两个控件都派生于基类TextBoxBase,而TextBoxBase派生于Control ...

  9. 使用 Windows 窗体 TextBox 控件创建密码文本框

    密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符. 创建密码文本框 将 TextBox 控件的 PasswordChar 属性设置为某个特定字符. PasswordChar 属 ...

随机推荐

  1. 用纯css写出三角形

    1.新建一个元素,随便什么元素,不过我习惯性的会用块元素来做.如果行内元素就display:block它.<div class="triangle"></div& ...

  2. mkimage的-a 和 –c参数和内核引导

    目录 一.mkimage工具简介二.-a参数与-e参数和内核引导的关系三.实例测试 3.1 -a参数与-e参数相同,可以将内核下载到SDRAM的任何地址,然后从这启动 3.2 -a参数与-e参数不同, ...

  3. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.10

    Every $k\times k$ positive matrix $A=(a_{ij})$ can be realised as a Gram matrix, i.e., vectors $x_j$ ...

  4. HDU 1078 FatMouse and Cheese 记忆化搜索DP

    直接爆搜肯定超时,除非你加了某种凡人不能想出来的剪枝...555 因为老鼠的路径上的点满足是递增的,所以满足一定的拓补关系,可以利用动态规划求解 但是复杂的拓补关系无法简单的用循环实现,所以直接采取记 ...

  5. sqlserver 2008 R2 分区表测试

    有一张表期中有100多w条数据 程序执行起来比较慢,想用分区表的办法,使查询变快一些. 方案如下 --查看分区信息SELECT * FROM sys.partition_range_values -- ...

  6. IE兼容性问题解决方案3--css中的overflow

    overflow:hidden:IE8下没效果? width:100%;IE6.7.8下必须有宽带,而且不能是auto: weight:auto; overflow-x:scroll; overflo ...

  7. poj 2104 K-th Number(主席树)

    Description You are working for Macrohard company in data structures department. After failing your ...

  8. 50道经典的JAVA编程题 (11-15)

    50道经典的JAVA编程题 (11-15),新年的第一天,继续啦...\(^o^)/~,这50道题都跨年了啊...哈哈 [程序11] TestTN.java 题目:有1.2.3.4个数字,能组成多少个 ...

  9. yum 安装 PHP,apache,nginx,mysql

    如果是Centos OS 64 位,首先更新 rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarc ...

  10. Altium Designer PCB 常用功能键

    altium designer 5种走线模式的切换 : shift+space 方格与格点的切换:View-Grids-ToggleVisible Grid Kind源点:Edit-Origin-Se ...