QueryString (Personal arrangement) for transferring values between ASP. NET pages, asp. netquerystring
QueryString
Querystring is also called a query string. The webpage URL is used to transmit data between pages. If you want to jump to page B from page A, you can use Request. Redirect ("B. aspx? Parameter Name = parameter value); after the page Jump, use Ruquest ["parameter name"] to receive parameters. This method is easy to use and does not require server resources. However, it is easy to tamper with and cannot pass objects. It is feasible to query strings only when the URL request page is used.
Advantages of this method: 1. Simple to use, it is very effective to transmit numbers or text values when security requirements are not high.
Disadvantages of this method: 1. Lack of security because its value is exposed in the URL address of the browser.
2. Objects cannot be passed.
Method of use: 1. Use the name and value to be passed in the Code on the Source Page to construct the URL address.
2. Use Response. Redirect (URL); to Redirect the code on the source page to the above URL.
3. Use Request. QueryString ["name"]; In the code on the target page to retrieve the value passed in the URL address.
Example: (1) a. aspx
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "a. aspx. cs" Inherits = "Web. a" %> <! DOCTYPE html>
(2) a. aspx. cs
Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; namespace Web {public partial class a: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {} protected void button#click (object sender, EventArgs e) {var url = "B. aspx? Name = "+ Label1.Text; Response. Redirect (url); // click the Button to Redirect to page B }}}
(3) B. aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="b.aspx.cs" Inherits="Web.b" %><!DOCTYPE html>
(4) B. aspx. cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Web{ public partial class b : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text= Request.QueryString["name"]; } }}
Ps: This article is based on my understanding on the Internet. If your rights and interests are inadvertently violated, please contact me.