We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Loading a page based on the url query string

Carla Romere
Carla Romere asked
on
Medium Priority
353 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?
Comment
Watch Question

Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011

Commented:
Use round brackets rather than square :
Page.Request.QueryString("txtCustNbr");
Software Engineer
CERTIFIED EXPERT
Top Expert 2011
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
F IgorDeveloper

Commented:
use in Page load:

Panel1.FindControl("txtCustNbr").Text=Page.Request.QueryString["txtCustNbr"];
Panel1.FindControl("txtCustNbr").Focus();
Carla RomereDirector of Information Technology

Author

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

Worked like a charm!!!!
Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011

Commented:
you can shorten that to :

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


Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.