Two common methods for passing parameters between webpages: querystring and session.

Source: Internet
Author: User
We are working on ASP. net web pages, it is inevitable to transfer parameters between different web pages. Below are two common methods to transfer parameters between web pages: the efficiency of parameter transfer is not discussed here. I personally prefer to use session transfer and release it immediately after use. It is very convenient.

Sending Page code:<Font Style="Background-color: # FFFF00"><Font Style="Background-color: # FFFF00">

Private   Sub imagebutton1_click () Sub Imagebutton1_click () Sub imagebutton1_click () Sub Imagebutton1_click ( Byval Sender As System. Object , Byval E As System. Web. UI. imageclickeventargs) Handles Imagebutton1.click
' Passing parameters through querystring or in session

' The following section is transmitted using querystring.
' Dim URL as string
' Url = "../search/localtemp. aspx. aspx? & Search = OK"
' If txtenterprisename. Text <> "" then
' Url = URL + "& E =" + txtenterprisename. Text
' End if
' If txtaddress. Text <> "" then
' Url = URL + "& A =" + txtaddress. Text
' End if
' If ddlprovice. selectedvalue <> "select Province" then
' Url = URL + "& P =" + ddlprovice. selectedvalue
' End if
' If ddlcity. selectedvalue <> "select city" then
' Url = URL + "$ c =" + ddlcity. selectedvalue
' End if
' If url = "../search/singledetailed. aspx? & Search = OK "then
' 'Error message
' End if
' Response. Redirect (URL)

' Next we use session to pass
Session ( " E " ) = Txtenterprisename. Text
Session ( " A " ) = Txtaddress. Text
Session ( " P " ) = Ddlprovice. selectedvalue
Session ( " C " ) = Ddlcity. selectedvalue
' Server. Transfer ()
Response. Redirect ( " ../Search/localtemp. aspx " )
End sub

</Font></Font>


Code of the Acceptance page: < Font Style = " Background-color: # FFFF00 " > < Font Style = " Background-color: # ffffff " > </ Font > < Font Style = " Background-color: # FFFF00 " >  


Private   Sub page_load () Sub Page_load ( Byval Sender As System. Object , Byval E As System. eventargs) Handles   Mybase . Load

' Put user code to initialize the page here
If   Not Ispostback Then
' If quesring is used
' Dim enname as string = request. querystring ["E"]
Dim Ename As   String
Dim Eaddress As   String
Dim Eprovice As   String
Dim Ecity As   String
Ename = Session ( " E " ). Tostring
Eaddress = Session ( " A " ). Tostring
Eprovice = Session ( " P " ). Tostring
Ecity = Session ( " C " ). Tostring
' ----
' Your code
' -----
' When you use finish
Session. Remove ( " E " )
Session. Remove ( " C " )
Session. Remove ( " A " )
Session. Remove ( " P " )
End   If
End sub </ Font > </ Font >

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.