Reputation: 2731
I my default.aspx have the following code in a page:
Label1.Text = datatable.Rows[0].Field<string>(1);
Response.Redirect("Welcome.aspx?Parameter=" + Label1.Text);
In my welcome.aspx page, I have the following page_load code:
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = Request.QueryString["Parameter"].ToString() + ", welcome to the website!";
}
When I view the website in a browser, on the Welcome page, I can see in the URL, that the parameter has been passed, however the label text is not updated. It almost seems like the page_load code isn't being run?
As requested, the aspx of the welcome page is below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 503px;
height: 249px;
margin-left: 67px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div style="margin-left: 280px">
<br />
<br />
<br />
<img alt="" class="auto-style1" src="Logo.jpg" /><br />
<br />
<br />
<asp:Label ID="Label2" runat="server">testing</asp:Label>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Can anybody explain why, and how to fix it?
Upvotes: 0
Views: 38
Reputation: 62290
Session State could be a better choice for that particular scenario, because you will need it whenever user lands on the WelcomePage.
Session["Parameter"] = datatable.Rows[0].Field<string>(1);
// Set a break point at Redirect, and check to make value is assigned
// to Session["Parameter"] before redirecting.
Response.Redirect("Welcome.aspx");
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = Session["Parameter"] + ", welcome to the website!";
}
Note: If the above solution doesn't solve the problem, the worst case you just delete Welcome.aspx
, create a new one without Master Page, and see Page_Load event fires.
Upvotes: 1