Click here to Skip to main content
14,423,678 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
Thanks a lot for your immediate response. I will explain my problem clearly and in more detail

this is my code in first page.
protected void btnLogin_Click(object sender, EventArgs e)
    {
        string pusername = NameTextBox.Text;
        Response.Redirect("~/OrderForm.aspx?username=" + pusername);
    }


this is my code in second page
protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          string username = Request.QueryString["pusername"];
          lblWelcome.Text += "Welcome," + username ;
      }
  }


when I try to get this variable pusername in the second page, I am not getting it. Can you please tell what could be the error. If i try it retrieve this values using their position in the querystring then it works.
Please tell me how to do with variables as I mentioned.
Posted
Updated 24-Nov-10 6:36am
v2
Comments
imaxis 25-Nov-10 2:44am
   
the QueryString key in your first page is "username",so you must get it by Request.QueryString["username"],not the "pusername"

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Instead of this:
string username = Request.QueryString["pusername"];


do this:
string username = Request.QueryString["username"];

Your querystring variable is 'username' & 'pusername' is a variable used to assign value in previous page.
   
Comments
lee.shakir 24-Nov-10 11:40am
   
Thanks for the reply but how it will fetch the user name entered in the first page. Your suggestion is not working. Read my problem again please
Sandeep Mewara 24-Nov-10 11:48am
   
I thought it would be better if I share an article with a sample attached: http://www.codeproject.com/KB/aspnet/QueryString.aspx

BTW, I did read your question and what I suggested is the way you work with querystring! It's your time now to read and try again :)
fjdiewornncalwe 24-Nov-10 12:48pm
   
Actually, this answer is correct based on the question you asked. The value you want to retrieve MUST be the same as the keyname you try to save it as. If that doesn't make sense, do some reading on the Querystring to understand why this is so. Cheers.
ShwetaSaxena 25-Nov-10 0:16am
   
The answer given by Mr.Sandeep is absolutely correct..
I did it nd its working....
You should also try...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100