简体   繁体   中英

Response.Redirect is not passing the value to another webform

I am trying to pass a textbox value in ClientGroupRegistration.aspx to a label in BorrowerRegistration.aspx . I am using the QueryString method, however, the following code is not working for me. No value gets passed to relationshipNameLabel.Text .

From ClientGroupRegistration.aspx

protected void nextPageButton_Click(object sender, EventArgs e) 
{
    ClientGroup client = new ClientGroup(this.addRelationshipName, this.addRelationshipComments);
    Response.Redirect("~/WebPages/BorrowerRegistration.aspx?Parameter=" + client.ClientName().ToString(), false); //ClientName() method returns a client name
}

To BorrowerRegistration.aspx

protected void Page_Load(object sender, EventArgs e)
{           
    relationshipNameLabel.Text = Request.QueryString["Parameter"];                  
}

When you redirect to BorrowerRegistration page, did you check URL? If It has no QueryString value then your Client Method returns NULL value. URL will be like :

BorrowerRegistration.aspx?Parameter=

Make sure the URL has your parameters in it, if it has them then you have to do something like this in BorrowerRegistration.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{           
    if (Request.QueryString["Parameter"] != null)
        relationshipNameLabel.Text = Request.QueryString["Parameter"].ToString();                  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM