• 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 {
                 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>");

  • 相关阅读:
    Valid Parentheses [LeetCode 20]
    线性回归的Spark实现 [Linear Regression / Machine Learning / Spark]
    逻辑回归的分布式实现 [Logistic Regression / Machine Learning / Spark ]
    Python爬虫之豆瓣-新书速递-图书解析
    安装软件包
    打包与压缩
    linux与linux间,互相拷贝文件
    网络管理
    重定向和管道
    索引
  • 原文地址:https://www.cnblogs.com/baimangguo/p/6255532.html
Copyright © 2020-2023  润新知