Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 5: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

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


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

Your querystring variable is 'username' & 'pusername' is a variable used to assign value in previous page.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900