码迷,mamicode.com
首页 > 其他好文 > 详细

Repeater、地址栏传值、Response--2016年12月30日

时间:2016-12-30 17:13:22      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:contract   set   inherits   onclick   提交   windows   object   server   12月   

Repeater

   Repeater支持以下5种模板 
      ● ItemTemplate : 对每一个数据项进行格式设置 【Formats each item from the data source.】 
      ● AlternatingItemTemplate : 对交替数据项进行格式设置 
      ● SeparatorTemplate : 对分隔符进行格式设置 
      ● HeaderTemplate : 对页眉进行格式设置 
      ● FooterTemplate : 对页脚进行格式设置 

例:
技术分享
 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ce.aspx.cs" Inherits="ce" %>
 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     <style>
10         #ta
11         {
12             width:100%;
13             text-align:center;
14         }
15         #hea
16         {
17             background-color:blue;
18         }
19         .tr1{
20             background-color:#c1e3ff;
21         }
22         .tr1:hover
23         {
24             background-color:#808080;
25         }
26         .tr2{
27             background-color:#1fddff;
28         }
29         .tr2:hover
30         {
31             background-color:#808080;
32         }
33     </style>
34 </head>
35 <body>
36     <form id="form1" runat="server">
37         <div>
38             <asp:Repeater ID="Repeater1" runat="server">
39                 <HeaderTemplate>
40                     <table id="ta">
41                         <tr id="hea">
42                             <td>编号</td>
43                             <td>姓名</td>
44                             <td>密码</td>
45                             <td>昵称</td>
46                             <td>性别</td>
47                             <td>生日</td>
48                             <td>民族</td>
49                             <td>班级</td>
50                         </tr>
51                 </HeaderTemplate>
52                 <ItemTemplate>
53                         <tr class="tr1">
54                             <td><%#Eval("Ids") %></td>
55                             <td><%#Eval("UserName") %></td>
56                             <td><%#Eval("PassWordStr") %></td>
57                             <td><%#Eval("NickName") %></td>
58                             <td><img src="<%#Eval("SexFile") %>" /></td>
59                             <td><%#Eval("Birthdaystr") %></td>
60                             <td style="<%#Eval("NationNameblu") %>"><%#Eval("NationName") %></td>
61                             <td><%#Eval("ClassName") %></td>
62                         </tr>
63                 </ItemTemplate>
64                 <AlternatingItemTemplate>
65                         <tr class="tr2">
66                             <td><%#Eval("Ids") %></td>
67                             <td><%#Eval("UserName") %></td>
68                             <td><%#Eval("PassWordStr") %></td>
69                             <td><%#Eval("NickName") %></td>
70                             <td><img src="<%#Eval("SexFile") %>" /></td>
71                             <td><%#Eval("Birthdaystr") %></td>
72                             <td style="<%#Eval("NationNameblu") %>"><%#Eval("NationName") %></td>
73                             <td><%#Eval("ClassName") %></td>
74                         </tr>
75                 </AlternatingItemTemplate>
76                 <FooterTemplate>
77                     </table>
78                 </FooterTemplate>
79             </asp:Repeater>
80         </div>
81     </form>
82 </body>
83 </html>
.aspx
技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 using System.Web.UI;
 6 using System.Web.UI.WebControls;
 7 using WindowsFormsApplication1.App_Code;
 8 
 9 public partial class ce : System.Web.UI.Page
10 {
11     protected void Page_Load(object sender, EventArgs e)
12     {
13         Repeater1.DataSource = new UserData().Select();
14         Repeater1.DataBind();
15     }
16 }
.aspx.cs

Request

  Request.QueryString :获取地址栏参数(以GET方式提交的数据) 

  地址后面接  ?key=value&key=value

  Request.QueryString方法还会把数据信息显示在客户端浏览器地址栏中,安全性较差。

 

  获取请求对象    Request["key"]

专门用来获取传递过来的值
1、获取地址栏传递过来的参数值 get
2、获取表单提交过来的参数值 post

 

Response: - 响应请求对象

Response.Redirect("路径?key=value");

Response.Write("打印的HTML");
Response.Write("<script>alert(‘哈哈哈哈哈‘);</script>");

 

Repeater、地址栏传值、Response--2016年12月30日

标签:contract   set   inherits   onclick   提交   windows   object   server   12月   

原文地址:http://www.cnblogs.com/hqxc/p/6237411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!