passing arguments into an aspx page

Posted on 2009-12-17
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

    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

    LVL 7

    Expert Comment

    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

    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

    Perfect!  Thank You!

    Expert Comment

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    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!
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now