How to Use S1 Variables to Change Web Pages
S1 variables are values sent in the URL query string, which is a string of variables you use to show dynamic content to a user. The S1 variable contains the page that you display for the user when the page is loaded. This type of coding lets you show a page dependent on the user input. Many programmers use it to display a page from an ad -- the ad contains the S1 variable and the code reads the variable value and displays the content accordingly.
Instructions
-
-
1
Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework," then click "Visual Studio" to open the Microsoft development software.
-
2
Click "File," then click "Open." A dialog box opens with a list of recent projects. Double-click your website project. The code opens in the center panel.
-
-
3
Type the following code to retrieve the value of the S1 variable:
string s1 = Request.QueryString["s1"];
This code creates an S1 variable and it retrieves the value of the S1 query string. You use the new S1 variable to display a dynamic web page.
-
4
Type the following code to display a web page that depends on the S1 variable value:
if (s1 == "mypage")
{ Response.Redirect("mypage.aspx"); }
if (s1 == "yourpage")
{ Response.Redirect("yourpage.aspx"); }
In this block of code, a web page is displayed depending on the value of S1. If the value of S1 is "mypage," then the website page "mypage.aspx" is displayed. If the value is "yourpage," then "yourpage.aspx" is shown.
-
5
Click the "Save" button at the top of the workspace. Click "Run" to test the new code. The pages open in the default browser.
-
1