?
Solved

Loading a page based on the url query string

Posted on 2011-04-21
5
Medium Priority
?
344 Views
Last Modified: 2012-05-11
I want to send a mass email merge to all of our customers and have individual links in the email for them to click to complete a brief survey in this format:
http://aert.com/vend_quest.aspx?txtCustNbr=10141
When they click that link, I want the page to load with their information.
That page only has one textbox on it. How can I load this particular customer's page simply by entering this URL?

I put this in the script section of the page itself:
        Page.Request.QueryString["txtCustNbr"];

The page loads, but just loads the default page, and the textbox is not populated with the customer's number.

So I moved that to the page load section of my code behind, and then I get this error:

Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Line 16:     {
Line 17:         //Panel1.FindControl("txtCustNbr").Focus(); <== this line works when it's not commented out
Line 18:         Page.Request.QueryString["txtCustNbr"];  <== Error here
Line 19:     }

How do I make this work correctly?
0
Comment
Question by:Carla Romere
  • 3
5 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35441600
Use round brackets rather than square :
Page.Request.QueryString("txtCustNbr");
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 35441639
Ignore that didn't see that you were using c#

It doesn't look like you are assigning the result of the Page.Request.QueryString["txtCustNbr"]; to anything i.e. :

string custnumber = Page.Request.QueryString["txtCustNbr"];
0
 
LVL 13

Expert Comment

by:F Igor
ID: 35441676
use in Page load:

Panel1.FindControl("txtCustNbr").Text=Page.Request.QueryString["txtCustNbr"];
Panel1.FindControl("txtCustNbr").Focus();
0
 

Author Comment

by:Carla Romere
ID: 35441728
http://aert.com/vend_quest.aspx?txtCustNbr=10141
In PageLoad -
        string custnumber = Page.Request.QueryString["txtCustNbr"];
        txtCustNbr.Text = custnumber;

Worked like a charm!!!!
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35442156
you can shorten that to :

        txtCustNbr.Text = Page.Request.QueryString["txtCustNbr"];


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question