Redirectig to a different webpage
protected void LoginButton_Click(object sender, EventArgs e)
{
string username = NameTextBox.Text;
Response.Redirect("~/orderpage.aspx?username=" + username);
}
Pass Information between Pages with the QueryString
protected void CheckoutButton_Click(object sender, EventArgs e)
{
string stuff = ProductTextBox.Text;
string username = Request.QueryString["username"];
string url = "~/summarypage.aspx?username=" + username + "&product=" + stuff; Response.Redirect(url);
}
Retrieving QueryString Information with Variables
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string username = Request.QueryString["username"];
WelcomeLabel.Text += ", " + username;
}
}
protected void CheckoutButton_Click(object sender, EventArgs e)
{
string stuff = ProductTextBox.Text;
string username = Request.QueryString["username"];
string url = "~/summarypage.aspx?username=" + username + "&product=" + stuff; Response.Redirect(url);
}
Using String.Format to build Proper String
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string username = Request.QueryString["username"];
string product = Request.QueryString["product"];
WelcomeLabel.Text = String.Format("Hey thanks {0}, your {1} is on its way!!!", username, product);
}
}
Saturday, January 31, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment