WebForm复杂控件

Repeater:

HeaderTemplate - 在加载开始执行一遍

ItemTemplate - 有多少条数据,执行多少遍

FooterTemplate - 在加载最后执行一遍

AlternatingItemTemplate - 交替项模板

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="lianxi.aspx.cs" Inherits="lianxi" %>
 2
 3 <!DOCTYPE html>
 4
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 8     <title></title>
 9 </head>
10 <body>
11     <form id="form1" runat="server">
12         <asp:Repeater ID="Repeater1" runat="server">
13             <HeaderTemplate>
14                 <table style="text-align:center">
15                     <tr style="color:white;padding:10px;">
16                         <td>UserName</td>
17                         <td>PsssWord</td>
18                         <td>NickName</td>
19                         <td>Sex</td>
20                         <td>Birthday</td>
21                         <td>Nation</td>
22                     </tr>
23              </HeaderTemplate>
24             <ItemTemplate>
25                 <tr style=" line-height: 1.5 !important;">">
26                     <td><%#Eval("UserName")%></td>
27                     <td><%#Eval("PassWord")%></td>
28                      <td><%#Eval("NickName")%></td>
29                     <td><%#Eval("Sex")%></td>
30                      <td><%#Eval("birthday")%></td>
31                     <td><%#Eval("Nation")%></td>
32                 </tr>
33             </ItemTemplate>
34             <FooterTemplate>
35               </table>
36             </FooterTemplate>
37         </asp:Repeater>
38
39
40
41
42     </form>
43 </body>
44 </html>

1  protected void Page_Load(object sender, EventArgs e)
2     {
3         if (!IsPostBack)
4         {
5             Repeater1.DataSource = new UsersDA().Select();
6             Repeater1.DataBind();
7         }
8     }

Image 图片,可以直接给URL

FileUpdate 文件上传

Calendar   日历

库存预警:
通过某个属性值判断后,将某条数据的样式进行更改

属性扩展的方式,写一个返回string类型的属性,返回的是CSS样式表样式

 1  /// <summary>
 2     /// 性别
 3     /// </summary>
 4     public bool Sex
 5     {
 6         get { return _Sex; }
 7         set { _Sex = value; }
 8     }
 9
10     public string SexStr
11     {
12         get { return _Sex ? "男" : "女"; }
13     }
14
15
16     private DateTime _Birthday;
17
18     /// <summary>
19     /// 生日
20     /// </summary>
21     public DateTime Birthday
22     {
23         get { return _Birthday; }
24         set { _Birthday = value; }
25     }
26
27     public string BirthdayStr
28     {
29         get { return _Birthday.ToString("yyyy年MM月dd日"); }
30     }
31
32
33     private string _Nation;
34
35     /// <summary>
36     /// 民族
37     /// </summary>
38     public string Nation
39     {
40         get { return _Nation; }
41         set { _Nation = value; }
42     }
43
44     public string NationName
45     {
46         get { return new NationData().Select(this._Nation).NationName; }
47
48     }
49
50     public string Age
51     {
52         get { return (DateTime.Now.Year - this._Birthday.Year).ToString(); }
53     }
54
55     public string Red
56     {
57         get
58         {
59             string end = "";
60             if (Convert.ToInt32(Age) >= 16)
61             {
62                 end = "";
63             }
64             return end;
65         }
66     }

为了让大家知道,属性值不一定非得是展示用

光棒效果:

 1     <script type="text/javascript">
 2         window.onload = function () {
 3             var items = document.getElementsByClassName("tr_Item");
 4             var oldColor = "";
 5             for (var i = 0; i < items.length; i++) {
 6                 items[i].onmouseover = function () {
 7                     oldColor = this.style.backgroundColor;
 8                     this.style.backgroundColor = "yellow";
 9                 };
10                 items[i].onmouseout = function () {
11                     this.style.backgroundColor = oldColor;
12                 };
13             }
14         };
15     </script>

时间: 2024-08-08 09:42:37

WebForm复杂控件的相关文章

webform简单控件和Repeater的使用

(一) <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <%# %> - 在Repeater数据展示中使用 (二)Repeater  数据展示 1.HeaderTemplate ---  先执行,执行一次 FooterTemplate --- 后执行,执行一次 ItemTemplate --- 在Header之后执行,有多少条数据绑定就执行多少次 AlterNatingItemTemp

webform简单控件

表单元素: 文本类: text password textarea hidden text,password,textarea实现控件:textbox   textmode属性选择password或multiline或singleline textmode的multiline对应textarea textmode的singleline对应text 可以对应text设置最大长度maxlength,而对于textarea无此项 隐藏域hidden对应控件为hiddenfield,用value可以对其

WebForm 简单控件、复合控件

简单控件: Label:被编译成span 样式表里设置lable的高度:  display:inline-block; Text  --文本 ForeColor  --字体颜色 Visible  --权限时使用 CssClass  --样式表 Literal:无任何元素,只会在其位置上将Text内容完全展示出来 重要属性只有:Text  --文本 TextBox: 不一定被编译成什么元素 属性:Text  --文本   TextMode - 它设置为什么值,被编译后将会是不同的一些表单元素 Si

webform简单控件和复合控件

简单控件: label:标签控件用于显示文本信息,用来获取或设置指定在label控件上显示的文字. 属性: text:获取或设置控件的文本内容. font:获取或设置控件的文本字体. forecolor:获取或设置控件中文本的颜色. bordercolor:获取或设置控件的边框颜色. borderstyle:获取或设置控件的边框样式. <asp:Label ID="Label4" runat="server" Text="Label">

WebForm 验证控件

验证控件一般是在注册的时候用到,是直接将JS代码封装到了控件里面,拉过来直接可以用,下面介绍一下主要用法: 1.CompareValidator:比较验证 常用属性:ControlToCompare 用来进行比较的控件的ID ControlToValidate  要验证的控件的ID Display  验证程序的的显示方式  (Dynamic 动态的) ErrorMessage 当验证的控件无效时在ValidationSummary中显示的消息 ValidationGroup 验证程序所属的组 V

Webform——验证控件

验证控件一般是在注册的时候用到,是直接将JS代码封装到了控件里面,拉过来直接可以用,下面介绍一下主要用法: 1.CompareValidator:比较验证 常用属性:ControlToCompare 用来进行比较的控件的ID ControlToValidate  要验证的控件的ID Display  验证程序的的显示方式  (Dynamic 动态的) ErrorMessage 当验证的控件无效时在ValidationSummary中显示的消息 ValidationGroup 验证程序所属的组 V

webform 简单控件

html中12个表单元素添加runat="server"后称为控件 Lable 编译之后是 <span></span> 属性:CssClass  编译成 class Text 编译成<span>和</span>之间的内容 Literal  编译之后是空的 TextBox 通过属性 TextMode 选择 SingleLine 编译为 <input type="text">, 选择Password编译为<

WebForm 常用控件

一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text="Label" BorderColor="Black" BorderStyle="Solid" BorderWidth="5px"></asp:Label> 编译完成后的元素时span(html) <span id

webform简单控件与复合控件

表单元素: 文本类:  --简单控件文本框:<input type="text" /> 密码框:<input type="password" />文本域:<textarea></textarea> 隐藏域:<input type="hidden" /> 按钮类:  --简单控件普通按钮:<input type="button" value="按钮1&q

4月12日 webform基本控件

服务器基本控件: button: text属性 linkbutton:text属性,它是一个超链接模样的普通button hyperlink: navigateurl:链接地址,相当于<a>标签 imagebutton:imageurl:指定图片路径,这也是一个按钮,执行click事件 image:就是一个img标签 textbox:     text:获取或设置文本     textmode:单行/多行/密码...     wrap:是否换行     rows:行数     columns: