QueryString (Personal arrangement) for transferring values between ASP. NET pages, asp. netquerystring

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.