0

Hi,
I want to pass cid genarated in selling.aspx to orderform.aspx .
How to retrieve the query string in orderform.aspx
I gave the code below in selling.aspx

SqlConnection con;
        SqlDataReader dr;
        con = new SqlConnection("Persist Security Info=False;Uid=sa;Password=q1w2e3/;Initial Catalog=YOGADATA;Data Source=PC-1");
        con.Open();
        t=0;
        
        SqlCommand com = new SqlCommand("select * from Custlogin", con);
        dr = com.ExecuteReader();
        dr.Read();
        
        try
        {
            do
            {
                if (TextBox1.Text.Trim() == dr[0].ToString().Trim() && TextBox2.Text.Trim() == dr[1].ToString().Trim())
                
                {
                    t = 1;
                    id = dr[2].ToString().Trim();
                }
            } while (dr.Read());
        }

        catch
        {
        }
        finally
        {
            con.Close();
            dr.Close();
        }
        if (t == 1)
        {
           [B][U] Response.Redirect("Orderform.aspx?id=");[/U][/B]        }
        else
        {
           Label11.Visible = true;
           Label11.Text = "Login failed,try again";

        }

please help me soon
Thank U.

Edited by Ezzaral: Added [code] [/code] tags. Please use them to format any code that you post.

3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by IdanS
0

Hi,
I have tried the same;
It is giving Null string.
Is there any wrong in my above code?
Thank You.

0

If you receive a null string it is because the query string was not passed in the request. You also need to read the Request.QueryString[] in the page that is receiving the request. IE if you call Response.Redirect("Orderform.aspx?id="); then you need to be reading the query string inside of OrderForm.aspx's page load event.

Here is some sample output of query strings:

--------
id[B]:[/B]  
url: /frmDevex.aspx
--------
id:  1234
url: /frmDevex.aspx?id=1234
--------
id:  1234
url: /frmDevex.aspx?ID=1234
--------
id:  
url: /frmDevex.aspx?ID=&abc=123
0

It's a security problem to write the id in the params string but you can do it like this:

Response.Redirect("Orderform.aspx?id=TheIdTextBox.text");

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.