Will Custode
Will Custode

Reputation: 4594

Passing Arguments to an ASP .NET Page

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!

Upvotes: 3

Views: 9896

Answers (2)

tzerb
tzerb

Reputation: 1433

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

Upvotes: 0

Brian Warshaw
Brian Warshaw

Reputation: 22984

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.

Upvotes: 9

Related Questions