Oracle 5.0 Reference Manual page 1891

Table of Contents

Advertisement

1. Select the
Default.aspx
the text property for the buttons to "Store Session Variable", "Clear Textbox", and "Show Session
Variable". These will be Button1,
ensure that no errors have been introduced.
2. Still in the Design View, double-click Button1. Now to the
code some the handler resembles the following:
protected void Button1_Click(object sender, EventArgs e)
{
Session["SessionString"] = TextBox1.Text;
}
You have created a new Session variable accessed using the key "SessionString". This will be set
to the text that was entered into the text box when
3. In Design View, double-click
from the text box. The code to do this is as follows:
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
}
The code simply assigns an empty string to the
4. In the Design View double-click
protected void Button3_Click(object sender, EventArgs e)
{
TextBox1.Text = (String)Session["SessionString"];
}
This will retrieve the session string and display it in the text box.
5. Now modify the
Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Text = "Enter some text";
}
}
This ensures that when the page loads the text box
6. Ensure that the solution is saved and then rebuild the solution.
7. Run the solution without debugging.
8. The form will be displayed. Enter some text into the text box. Now click Store Session Variable. At
this point you have stored the string in a session variable.
9. Now click Clear Text to clear the text box.
10. Now click Show Session Variable to retrieve and display the session variable.
11. Refresh the page to destroy the form and display a new form.
12. Click Show Session Variable the text box will display the stored session variable, demonstrating
that the refreshing the page does not destroy the session variable.
This illustrates that the session state data is not destroyed when a page is reloaded.
Connector/Net Tutorials
and switch to Design View. Add a text box and three buttons. Change
and
Button2
Button3
to add its click event handler. This button needs to clear text
Button2
Text
and modify the click handler as follows:
Button3
method as follows:
1871
respectively. Build your solution to
Button1_Click
is clicked.
Button1
property of the text box.
property is reset.
Text
event handler add

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents