webform Repeater、地址栏传值、Response

Repeater: 重复器

  <HeaderTemplate> - 开头,只执行一次的内容

  <ItemTemplate> - 需要重复执行的部分

  <AlternatingItemTemplate> - 需要与上面模板进行交替执行的部分

  <FooterTemplate> - 尾部,只执行一次,在重复的部分执行完之后再执行

展示数据库中的数据:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
    <style>
        #table {
            width: 100%;
            text-align: center;
            background-color: blue;
        }

        .t-header {
            color: white;
            font-weight: bold;
        }

        .t-body {
            background-color: #808080;
        }

        .t-body1 {
            background-color: #00ff21;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">

        <asp:Repeater ID="Repeater1" runat="server">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WindowsFormsApplication1.App_Code;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Repeater1.DataSource = new UsersData().Select();
        Repeater1.DataBind();

    }
}

后台

 

QueryString: - get提交方式/地址栏传值

  原理:地址栏后面接 ?key=value&key=value 在后台代码中可以通过这些key来接受需要的字符串

  优点:不占用服务器内存,执行快  缺点:直接显示在了地址栏上,安全性差

Request:  -  获取请求对象

  使用:在页面加载事件中 string a =Request["key"];

Response: - 响应请求对象

  Response.Redirect("想要跳转的页面地址");

  Response.Write("想要在页面中插入的语句,例如:<script>alert('哈哈哈哈');</script>");

posted @ 2017-01-06 11:08  不会撩妹的白芒果  阅读(131)  评论(0编辑  收藏  举报