Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In the below code, if i try to pass values using variables its not working
but if i pass by their positions its not displaying data in the next page.
Can some please tell me why
protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string username = Request.QueryString[0];
        string product = ProductTextBox.Text;
        //string url = "~/SummaryPage.aspx?username=&" + username + & "&product=" + product;
        string url = "~/SummaryPage.aspx?username=" + username + "&product=" + product;

        Response.Redirect(url);
    }
Posted
Updated 24-Nov-10 3:45am
v3
Comments
thatraja 25-Nov-10 1:18am    
Can you please explain your question little bit. What do you mean "their positions its not displaying data in the next page"?

Just a small error:

string url = "~/SummaryPage.aspx?username=&" + username + & "&product=" + product;

You'll have to delete the first and the second ampersand. Third one is ok.

BTW: with the second ampersand being were it is this code should not even compile!

cheers

Manfred
 
Share this answer
 
Comments
thatraja 24-Nov-10 9:44am    
Sorry dude, It's my mistake in edit, I'll edit
I see two problems. First is the ampersand after username: a browser will interpret this as username having an empty value, and product as the third parameter, not the second. Second, you have a stray ampersand outside of any quotes. Try this:
C++
string url = "~/SummaryPage.aspx?username=" + username + "&product=" + product;
 
Share this answer
 
Comments
thatraja 24-Nov-10 9:46am    
Sorry dude, It's my mistake in edit, I'll edit

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