BeanSoftware Logo
 

 
ASP.NET Database Search Control
 
 

 
 Home
    Shop
    Advertise
    Write For Us
    Affiliate
    Newsletter
    Contact

Can I Pass QueryString Variable From Classic ASP To ASP.NET?

You can pass QueryString variables from classic ASP to ASP.NET pages. To send variable with name = ID and value = 22, you can use this ASP code:

[ VbScript ]

<%
  Response.Redirect "Default.aspx?id=22"
%>

Then, in Default.aspx, you can use this ASP.NET server side code to read data:

[ C# ]

protected void Page_Load(object sender, EventArgs e)
{
    int myID;
    if (Request.QueryString["ID"] != null)
    {
        // Read value from query string
        myID = Convert.ToInt32(Request.QueryString["ID"]);
    }
    else
    {
        // If there is nothing in query string, use default value
        myID = 1;
    } 
    Response.Write(myID.ToString());
}

[ VB.NET ]

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myID As Integer
    If Request.QueryString("ID") = Nothing Then
        ' Read value from query string
        myID = Convert.ToInt32(Request.QueryString("ID"))
    Else
        ' If there is nothing in query string, use default value
        myID = 1
    End If
    Response.Write(myID.ToString())
End Sub



Related articles:

1. How To Find Which Version of .NET Framework Is Used?
2. Site Maps In ASP.NET
3. JW FLV Player ASP.NET Control - C# Source Code

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback



Copyright © 2002-2008 Bean Software. All rights reserved.