How to use Query String in ASP.NET Application

By
Query string is a method that store the state information on the client end.If we want to send some information from the previous page to the Next page then we can send the information as the Bar of URL by specifying '?' symbol within URL after the '?' mark.whatever URL specify is consider as Query string.Query string is not secure because their values are exposed to the Internet through the URL .
There are some steps to understand the whole concept of Query string.which are given below:-
Step 1:- First open your visual studio-->File--> New-->website -->select ASP.NET  Empty website -->OK-->Open Solution Explorer --> Add two web forms -->Drag and Drop Label,Button and Text Box on first web form as shown below:-


home page
Step 2:- Now Double Click on 'Submit' button--> write the following codes as given below:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Query_string : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
 Response.Redirect("default.aspx?id="+TextBox1.Text+"&Mobile="+TextBox2.Text+"");
        }
    }
}

Step 3:- Now Drag and Drop two label control on second web form as shown below:-


information

Step 4:- Now Double click on second web form and write the following codes on page load as given below:-

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = Request.QueryString["id"];
        Label2.Text = Request.QueryString["Mobile"];
    }
}

Step 5:- Now Run Application (press F5)-->and enter the required fields as shown below:-


details
Step 6:- Now press the Submit Button,You will see that first page information(User Name and Mobile Number) send to second page through the URL  as show below:-


store data


For More:-
  1. Web form controls
  2. state management
  3. create captcha image in asp.net application
  4. oops concepts
  5. create setup file
  6. Interview questions

To Get the Latest  Free Updates Subscribe
                     Download

0 comments:

Post a Comment

Powered by Blogger.