DragonInCresent
DragonInCresent

Reputation: 75

I cannot pass more than one value in QueryString

My ASP.NET application has stopped working after I migrated it to another server.

The problem is that I cannot send more than one value via the query string.

The URL I'm trying looks like this:

ThisIsSecondPage.aspx?Mode=Edit&ID=0001

I can capture the value of Mode in ThisIsSecondPage.aspx, but ID is blank.

I also tried to change ID to something line A0001, but it did not work.

I also tried:

ThisIsSecondPage.aspx?Mode=Edit<and>ID=0001 

Can anyone help me please?

Upvotes: 0

Views: 76

Answers (2)

Mike
Mike

Reputation: 721

You are passing query string correctly.

ThisIsSecondPage.aspx?Mode=Edit&ID=0001

In second page, Use as below

For Mode

string ModeValue = Request.QueryString["Mode"];

or in short form,

string ModeValue = Request["Mode"];

For ID

string IDValue = Request.QueryString["ID"];

or in short form,

string IDValue = Request["ID"];

Upvotes: 0

Morteza Jangjoo
Morteza Jangjoo

Reputation: 1790

send querystring like this

ThisIsSecondPage.aspx?Mode=Edit&ID=0001

and recive in page_load event of ThisIsSecondPage page:

protected void Page_Load(object sender, EventArgs e)
    {
        string ModeParam = "";
        string IDparam = "";
        if(Request.Params["Mode"] !=null)
            ModeParam = Request.Params["Mode"].ToString();
        if (Request.Params["ID"] != null)
            IDparam = Request.Params["ID"].ToString();

    }

Upvotes: 1

Related Questions