Asp tutorial. net get url parameter value code
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.html controls;
Public partial class querystringsender: system. web. ui. page
{
Protected void page_load (object sender, eventargs e)
{
}
Protected void pai_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 = "pixel PX"
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.html controls;
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 "abnormal normal ":
Lbldate. font. size = fontunit. large;
Break;
Case "cmdsmall ":
Lbldate. font. size = fontunit. small;
Break;
}
}
}
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 = "pai_click">
</Asp: button>
<Asp: button id = "abnormal normal" 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>