分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

WebForm复杂控件

发布时间:2023-09-06 01:37责任编辑:熊小新关键词:Web

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 SexStr11 ????{12 ????????get { return _Sex ? "男" : "女"; }13 ????}14 15 16 ????private DateTime _Birthday;17 18 ????/// <summary>19 ????/// 生日20 ????/// </summary>21 ????public DateTime Birthday22 ????{23 ????????get { return _Birthday; }24 ????????set { _Birthday = value; }25 ????}26 27 ????public string BirthdayStr28 ????{29 ????????get { return _Birthday.ToString("yyyy年MM月dd日"); }30 ????}31 32 33 ????private string _Nation;34 35 ????/// <summary>36 ????/// 民族37 ????/// </summary>38 ????public string Nation39 ????{40 ????????get { return _Nation; }41 ????????set { _Nation = value; }42 ????}43 44 ????public string NationName45 ????{46 ????????get { return new NationData().Select(this._Nation).NationName; }47 48 ????}49 50 ????public string Age51 ????{52 ????????get { return (DateTime.Now.Year - this._Birthday.Year).ToString(); }53 ????}54 55 ????public string Red56 ????{57 ????????get58 ????????{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>

WebForm复杂控件

原文地址:https://www.cnblogs.com/zxh1314/p/8302021.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved