• ASP.NET页面之间传值QueryString(1)


    QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。

      这种方法的优点:1.使用简单,对于安全性要求不高时传递数字或是文本值非常有效。
      这种方法的缺点:1.缺乏安全性,由于它的值暴露在浏览器的URL地址中的。
              2.不能传递对象。

      使用方法:1.在源页面的代码中用需要传递的名称和值构造URL地址。
           2.在源页面的代码用Response.Redirect(URL);重定向到上面的URL地址中。
           3.在目的页面的代码使用Request.QueryString["name"];取出URL地址中传递的值。

    这是indextest.aspx后台页面:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Web;
     4 using System.Web.UI;
     5 using System.Web.UI.WebControls;
     6 
     7 public partial class JajaWeixinQianduanWeb_WoYaoDingCan_indextest : System.Web.UI.Page
     8 {
     9     protected void Page_Load(object sender, EventArgs e)
    10     {
    11 
    12     }
    13 
    14     protected void btn_chuanzhi_Click(object sender, EventArgs e)
    15     {
    16         string s_url;
    17         s_url = "indextestlist.aspx?name=" + this.txt_chuanzhi.Value;
    18         Response.Redirect(s_url); 
    19     }
    20 }

    这是indextestlist.aspx后台页面:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Web;
     4 using System.Web.UI;
     5 using System.Web.UI.WebControls;
     6 
     7 public partial class JajaWeixinQianduanWeb_WoYaoDingCan_indextestlist : System.Web.UI.Page
     8 {
     9     protected void Page_Load(object sender, EventArgs e)
    10     {
    11         this.lab_zhi.Text = Request.QueryString["name"]; 
    12     }
    13 }
  • 相关阅读:
    c++ 类 总结
    SQLite入门与分析(四)Page Cache之事务处理(3)
    SQLite入门与分析(三)内核概述(1)
    SQLite入门与分析(八)存储模型(1)
    glibc笔记——strlen
    SQLite入门与分析(二)设计与概念
    线性时间选择问题——分治
    SQLite入门与分析(二)设计与概念(续)
    浅谈c语言中的字符串
    SQLite入门与分析(六)再谈SQLite的锁
  • 原文地址:https://www.cnblogs.com/liubeimeng/p/3836963.html
Copyright © 2020-2023  润新知