c#_DropdownList Panel Textbox 控件交互使用,有autopostback和没有的区别
<%@ 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和没有的区别的更多相关文章
- ASP.Net TextBox控件只允许输入数字
原文:ASP.Net TextBox控件只允许输入数字 1.1.在Asp.Net TextBox 控件的 OnKeyPress 事件中指定输入键盘码必须为数字: <asp:TextBox ID= ...
- JS与APP原生控件交互
"热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显 ...
- 关于C#开发WEB项目TextBox控件的自适应高问题解决办法!
前两天做WEB开发时候遇到了一个小问题TextBox 控件要根据输入的内容多少自动改变大小,并且这个大小要求是在本页面内最大化.也就是 Width="100%" Height=&q ...
- [转载]ASP.NET中TextBox控件设立ReadOnly="true"后台取不到值
原文地址:http://www.cnblogs.com/yxyht/archive/2013/03/02/2939883.html ASP.NET中TextBox控件设置ReadOnly=" ...
- 设置TextBox控件的TextMode属性
我想在程式代碼中將TextBox控件的TextMode属性设置為Password,寫成TextBox1.TextMode=MultiLine和TextBox1.TextMode="Multi ...
- 验证标题是否存在(TextBox控件失去焦点验证)
首先解释两个属性, AutoPostBack 属性用于设置或返回当用户在 TextBox 控件中按 Enter 或 Tab 键时,是否发生自动回传到服务器的操作. 如果把该属性设置为 TRUE,则启用 ...
- 关于ASP.net TextBox控件的失去焦点后触发其它事件
编写人:CC阿爸 2015-2-02 今天在这里,我想与大家一起分享如何处理的ASP.net TextBox控件的失去焦点后触发其它事件的问题,在此做个小结,以供参考.有兴趣的同学,可以一同探讨与学习 ...
- C# Windows - TextBox 控件
.NET Framework内置了两个基本控件来提取用户输入的文本: TextBox和RichTextBox.这两个控件都派生于基类TextBoxBase,而TextBoxBase派生于Control ...
- 使用 Windows 窗体 TextBox 控件创建密码文本框
密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符. 创建密码文本框 将 TextBox 控件的 PasswordChar 属性设置为某个特定字符. PasswordChar 属 ...
随机推荐
- hdu 3033 I love sneakers!
I love sneakers! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Spring--通过注解来配置bean
Spring通过注解配置bean 基于注解配置bean 基于注解来配置bean的属性 在classpath中扫描组件 组件扫描(component scanning):Spring能够从classpa ...
- 【Web前沿技术】纯 CSS3 打造的10个精美加载进度条动画
之前向大家介绍8款优秀的 jQuery 加载动画和进度条插件,今天这篇文章向大家推荐10个纯 CSS3 代码实现精美加载进度条动画效果的方案.加载动画和进度条在网站和 Web 应用中的使用非常流行,特 ...
- Jmeter性能测试之如何写Java请求测试用例类
一. 引言: 最近工作中的一个项目要求做性能测试,该项目由提供服务的几个应用组成,选用的框架是阿里巴巴公司开源的服务框架Dubbo.关于Dubbo的介绍,网上也有很多资料,本人只是做了粗略的了解,没有 ...
- 【译】 AWK教程指南 附录B-Actions
Actions 是由下列指令(statement)所组成: 表达式 ( 函数调用,赋值...) print 表达式列表 printf( 格式化字符串, 表达式列表) if( 表达式 ) 语句 [els ...
- KNN算法java实现代码注释
K近邻算法思想非常简单,总结起来就是根据某种距离度量检测未知数据与已知数据的距离,统计其中距离最近的k个已知数据的类别,以多数投票的形式确定未知数据的类别. 一直想自己实现knn的java实现,但限于 ...
- NOIP 2015 神奇的幻方
模拟,注意为偶数的情况 #include<cstdio> #include<cstring> #include<cstdlib> #include<iostr ...
- lcov收集覆盖率
1.gcov 1.1 什么是gcov 首先我们要了解什么是gcov,gcov伴随gcc 发布.gcc编译加入-fprofile-arcs -ftest-coverage 参数生成二进制程序,执行测试用 ...
- Zend studio注册码
Zend studio 7.1 注册码 username:lisijie_orgLicense Key:3F4F495657BF3F4A95657BF3 Zend studio 8 注册码(适用于7. ...
- PHP算法之二分查找和顺序查找
一.二分查找 (数组里查找某个元素) /** * 二分查找 (数组里查找某个元素) * $k为要查找的关键字(注:待查找的数组元素为奇数个)$low为查找范围的最小键值,$high为查找范围的最大键值 ...