0% found this document useful (0 votes)
22 views2 pages

Datetimedatetime: Using Using Using Using Using Using Using Public Partial Class

This C# code defines a class that extends the Page class. It uses ViewState to store an ArrayList across postbacks. On page load, if it is not a postback, a new empty ArrayList is added to ViewState. When a button is clicked, it gets the ArrayList from ViewState, adds a new Encuentro object to it with date, rival, stadium, and time from textboxes, and saves it back to ViewState. It also adds the selected date to a ListBox.

Uploaded by

Sandro Ventura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Datetimedatetime: Using Using Using Using Using Using Using Public Partial Class

This C# code defines a class that extends the Page class. It uses ViewState to store an ArrayList across postbacks. On page load, if it is not a postback, a new empty ArrayList is added to ViewState. When a button is clicked, it gets the ArrayList from ViewState, adds a new Encuentro object to it with date, rival, stadium, and time from textboxes, and saves it back to ViewState. It also adds the selected date to a ListBox.

Uploaded by

Sandro Ventura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

DateTimeDateTime

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{

protected void Page_Load(object sender, EventArgs e)


{
if (!Page.IsPostBack)
{
ArrayList enc = new ArrayList();

ViewState.Add("encuentro", enc);

protected void Button1_Click(object sender, EventArgs e)


{
ArrayList encuentro = new ArrayList();
encuentro = (ArrayList) ViewState["encuentro"];
DateTime fecha =
Convert.ToDateTime(Calendar1.SelectedDate.ToShortDateString());
string rival = TextBox1.Text;
string estadio = TextBox2.Text;
string hora = TextBox3.Text;
encuentro.Add(new Encuentro(fecha, rival, estadio, hora));
ViewState["encuentro"] = encuentro;
ListBox1.Items.Add(Calendar1.SelectedDate.ToString());

}
}

You might also like