<%@ 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. 【转】如何下载并编译Android4.0内核源码goldfish(图文)

    原文网址:http://blog.csdn.net/flydream0/article/details/7070392 关于如何下载Android4.0源码,请查看我的博客内另一篇文章(同样是图文教程 ...

  2. DOM的定义及DOM相关

    DOM : Document Object Model 文档对象模型文档:html页面文档对象:页面中元素文档对象模型:定义 为了能够让程序(js)去操作页面中的元素 DOM会把文档看作是一棵树,同时 ...

  3. (二)学习JavaScript之setInterval和clearInterval方法

    参考:http://www.w3school.com.cn/jsref/met_win_setinterval.asp HTML DOM Window 对象 定义和用法 setInterval() 方 ...

  4. 陈灯WGF双缓冲绘图框架

    “木丸子童屋”,专售各类儿童玩具,价格优惠,请大家多多支持:http://shop65552598.taobao.com/ WGF(windows graphic foundation)为window ...

  5. ubuntu启用root用户

    在安装Ubuntu时系统会提示你创建一个用户,但是该用户不具备ROOT权限.但是此时系统是有root用户的,root密码是随机的,如果你想使用root用户需要更改root密码.用你安装系统时创建的用户 ...

  6. Web技术导论复习大纲

    1. 什么是URL,其一般形式是什么? 资源类型://网址[:端口号][/[文件路径/文件名]][?参数名=参数值&参数名=参数值...] 2. 什么是B/S模式,与C/S模式相比有哪些优越性 ...

  7. hadoop cdh 4.5的安装配置

    春节前用的shark,是从github下载的源码,自己编译.shark的master源码仅支持hive 0.9,支持hive 0.11的shark只是个分支,不稳定,官方没有发布release版,在使 ...

  8. Nine simple steps to enable X.509 certificates on WCF- 摘自网络

    Table of contents Introduction and goal Beginner WCF FAQs Step 1: Create client and server certifica ...

  9. 射频识别技术漫谈(3)——能量、调制【worldsing 笔记】

    无源和免接触是非接触式IC卡相对于接触式IC卡的两大特点.无源是指卡片上没有电源,免接触是指对卡片的读写操作不必和读写器接触.非接触式智能卡也是IC卡,而卡上的IC即集成电路工作时肯定是需要电源的,卡 ...

  10. jquery判断input值不为空 val()

    <input type="text" class="searchbox" /> <script type='text/javascript'& ...