Материал из .Net Framework эксперт
Get value from query string
File: Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="QueryStringSender" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button id="cmdLarge"
runat="server"
Text="Large Text Version"
OnClick="cmd_Click">
</asp:Button>
<asp:Button id="cmdNormal" runat="server" Text="Normal Version" OnClick="cmd_Click"></asp:Button>
<asp:Button id="cmdSmall" runat="server" Text="Small Text Version" OnClick="cmd_Click"></asp:Button>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class QueryStringSender : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void cmd_Click(object sender, EventArgs e)
{
Response.Redirect("NextPage.aspx" + "?Version=" +
((Control)sender).ID);
}
}
File: NextPage.aspx
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="NextPage.aspx.cs"
Inherits="QueryStringRecipient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label id="lblDate"
runat="server"
Width="528px"
Height="112px"
Font-Names="Verdana"
Font-Size="Large"
EnableViewState="False">
</asp:label>
</div>
</form>
</body>
</html>
File: NextPage.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class QueryStringRecipient : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblDate.Text = "The time is now:<br>" + DateTime.Now.ToString();
switch (Request.QueryString["Version"])
{
case "cmdLarge":
lblDate.Font.Size = FontUnit.XLarge;
break;
case "cmdNormal":
lblDate.Font.Size = FontUnit.Large;
break;
case "cmdSmall":
lblDate.Font.Size = FontUnit.Small;
break;
}
}
}