3

So I've recently started working with ASP .NET but I am very familiar with other .NET frameworks. The application I'm working on needs to take in an string index as a command line-style argument. Right now in my Page class I have a const string that I'm using as a placeholder. So the question I have is a two parter:

1- How do I set up my applications innerts to recieve an argument that is passed in when the page is opened?

2- How do I pass that argument in to the page (especially while I'm working in VS 2010)?

Much Thanks!

2 Answers 2

9

You pass arguments to web pages with request variables (ever hear of POST or GET?). The simplest way is to append the variables to the end of the url like this:

http://localhost/Default.aspx?varname=varvalue&othervarname=othervarvalue

In your codebehind, you can access the request variables with Request.QueryString.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much! Like I said I'm new to web dev so I didn't know it worked that way. Much appreciated! For all who see this, this worked for my problem.
0

For #2: In your project config on VS2010, to to the 'Web' tab and set the option to specific page with the desired URL: http://localhost/Default.aspx?varname=varvalue&othervarname=othervarvalue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.