Page view counter
HomeLearnVideosHow Do I: Pass Information From One Page to Another Using a Query String  

How Do I: Pass Information From One Page to Another Using a Query String

In this video Chris Pels will show how information can be passed from one page to another using a query string. First, see how to construct a query string including variable names and values from information on a data entry form. Next, see how to access the query string information when the page is posted including how multiple query string variables are handled. As part of the server side processing of query string information, see how to implement validation for existence of query string variables and if they contain the expected type of data. Finally, learn how to pass special characters including a space and an ampersand in a query string by encoding the string.

Presented by Chris Pels

Duration: 25 minutes, 9 seconds

Date: 26 June 2008

Watch the video   |   Download the video   |   Get VB code  or  C# code

Video downloads: WMV | Zune | iPod | PSP | MPEG-4 | 3GP

Audio downloads: AAC | WMA | MPEG-4 | MPEG-3 | MPEG-2

Comments : 21

Leave a Comment

abelanet : On June 26, 2008 7:30 PM said:

Very good video - explained in a very understandable way. Thanks

j.shafee : On June 27, 2008 5:16 AM said:

This is too cool!Thanks Chris Pels!

uwspstar : On June 27, 2008 9:40 AM said:

very nice video

zmb94 : On June 27, 2008 2:43 PM said:

The C# vesion isn't available.

kemalemin : On June 29, 2008 1:44 AM said:

Very basic and irrelevant video! at least it is not something that requires first page publishing on ASP.NET website. Building querystrings is something that every single person who is involved in web programming learns the very first thing.

The video should instead concantrate  

1) Security and Validation of querystrings

2) The limits and limitations of querystrings.

3) When and when not to use querystrings

4) comparison between page.transfer, previouspage. and other methods of retrieving form information and transferring to other target pages.

Nezdet : On July 01, 2008 12:56 PM said:

Nice video Chris!

Iam about to create a serachpage for my project. And Iam about to use querystring to send over searchinformation to the samepage (By samepage I mean, the results will be shown in the searchpage)

Do you recomend us to use the alternative that you showed on the vide

OR

Should we change the Form-tags Method="get"

Which one should you prefer, and why?

(My querystring picks upp all the unnecessary strings if i put the <form method=get>, it get's a bit dirty-querystring)

Hope you can answer this!!

THANKS

rhiana : On July 01, 2008 11:08 PM said:

@kemalemin: Please don't front urself

These are tutorials, it's suppose to be basic...

Nice Video Chris Pels, I've learned a lot from u

DMAsuncion : On July 02, 2008 2:45 AM said:

Thanks a lot, God Bless..

shailatlas : On July 03, 2008 3:31 AM said:

Hello Chris,

Can you please tell me what is the software you use to record the session ?

Thanks

sfrandys : On July 03, 2008 2:55 PM said:

The link that is to be the C# version contains the VB version.  Could this please be changed?  Thanks

chaoslegion05 : On July 10, 2008 10:04 AM said:

The C# link contains the VB code!

tclonyem : On July 10, 2008 11:36 AM said:

Below, I've written the C# code for both code files:

1) Default.aspx.cs

namespace ASPQueryString

{

   public partial class _Default : System.Web.UI.Page

   {

       protected void Page_Load(object sender, EventArgs e)

       {

       }

       protected void btnSubmit_Click(object sender, EventArgs e)

       {

          string targetURL;

          targetURL = "Target1.aspx?";

          targetURL += "CustID=" + Server.UrlEncode(txtCustomerId.Text.Trim());

           targetURL += "&CustName=" + Server.UrlEncode(txtCustomerName.Text.Trim());

           targetURL += "&ProdID=" + Server.UrlEncode(txtProductID.Text.Trim());

           targetURL += "&ProdDesc=" + Server.UrlEncode(txtProductDescription.Text.Trim());

         Response.Redirect(targetURL);

       }

   }

}  

2) Target1.aspx.cs

namespace ASPQueryString

{

   public partial class Target1 : System.Web.UI.Page

   {

     protected void Page_Load(object sender, EventArgs e)

       {

        if ((Request.QueryString["CustID"] != null))

           {

               labCustID.Text = Request.QueryString["CustID"].ToString();

           }

        if ((Request.QueryString["CustName"] != null))

           {

              labCustName.Text = Request.QueryString[1].ToString();

           }

           if ((Request.QueryString["ProdID"] != null))

           {

               labProdID.Text = Request.QueryString["ProdID"].ToString();

           }

           if ((Request.QueryString["ProdDesc"] != null))

           {

               labProdDesc.Text = Request.QueryString[3].ToString();

           }

       }

   }

}  

ngonka2003 : On July 15, 2008 5:13 AM said:

Merci pour cette demonstration tres bien presentée.

asater : On August 22, 2008 6:40 AM said:

Very nice video

Thank you

keep it coming

bsvnhll : On August 28, 2008 6:06 AM said:

this could have been more usefull

cyrussullivan : On September 13, 2008 3:38 PM said:

I am trying to figure out how to bind a query string to a form view item inserted event so that when i hit the insert button i will be taken to a page displaying the inserted data. So far I cant find a tutorial that says how to do that.

anisurrahman : On October 14, 2008 4:56 PM said:

Thank you very much...

agoyal : On October 15, 2008 4:25 AM said:

This is a very helpful video tutorial.

agoyal : On October 15, 2008 4:25 AM said:

This is a very helpful video tutorial.

ccgilson : On November 07, 2008 8:13 AM said:

Very clear and helpful, but for me the video wastes too much time with setting up. The tutorial's title is: 'How Do I: Pass Information From One Page to Another Using a Query String' and not 'How Do I: Place basic controls into an HTML page, name them, position them and then pass Information From One Page to Another Using a Query String'

djafer : On November 12, 2008 8:14 AM said:

thanx

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities