Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


passing arguments into an aspx page

Posted on 2009-12-17
Medium Priority
Last Modified: 2012-05-08
I've used the below to pass arguments into a windows form.  The form uses these arguments to run a stored procedure to fill a datagrid. I'm passing the arguments from an outside application.
I'm new to aspx pages.  Can you point me the direction of how I could do something similar for opening an aspx page (c#)?  

static void Main(string[] args)
      argument1= (args[0]);
      argument2 = (args[1]);
      argument3 = (args[2]);

      Application.Run(new Form1());
Question by:LATurk
LVL 11

Accepted Solution

five22bags earned 2000 total points
ID: 26073426
You will want to user the querystring. If you call an aspx page like so:


you can access it like this in  the codebehind (processme.aspx.cs):

protected void Page_Load(object sender, EventArgs e)
        string arg1 = Request.QueryString["id"];
        string arg2 = Request.QueryString["this"];

Open in new window


Expert Comment

ID: 26073511
When you call an aspx page


Now, When you reach the destination page. You should request these querystring value as follows

string args1=Request.QueryString["arg1"];
string args2=Request.QueryString["arg2"];
string args3=Request.QueryString["arg3"];

Now, use the values arg1,arg2,arg3 as an argument for the Stored procedure..
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 26073541

you can pass that information through get method, or through session variables.

Through get method,

response.redirect("page.aspx?id1=" & val1 & "&id2=" & val2)

to retrieve in other page:


or through session variables

session("id1") = val1
session("id2") = val2

to retrieve in other page:

id1 = session("id1")
id2 = session("id2")

Author Closing Comment

ID: 31667403
Perfect!  Thank You!

Expert Comment

ID: 26073755
There are several ways, the easiest is via QueryString:

You create a button on the main page, for example default.aspx

You add a function in the OnClick property, in this case "TESTBUTTON_ONCLICK"

Now we get to the part of the code, Defautl.aspx.cs

protected void TESTBUTTON_ONCLICK(object sender, EventArgs e)

Now in Page_Load property of the page you're going through data

String auxStr = String.Empty;

auxStr += Response.QueryString["param1"].ToString();
auxStr += Response.QueryString["param2"].ToString();
auxStr += Response.QueryString["param3"].ToString();


auxStr += Response.QueryString[0].ToString();
auxStr += Response.QueryString[1].ToString();
auxStr += Response.QueryString[2].ToString();



Another way is to add the property "Action" page Default Default2.aspx name, and you must use Input controls, and in the Page_Load Default2 takes the values Request.Form [ "nameObject"].

I hope you serve any of them, Best Regards


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

579 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