13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

252<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>font-bold="True"BorderWidth="1px" Font-Size="10pt"ForeColor="#d8cd03" Height="25px" />The C# portion of the code adds content to a Label control. In the <strong>ASP</strong>.<strong>NET</strong> portion, theCalendar propertyOnSelectionChangedis the event used to call the C# event handler. The content is determined by the Calendarinstance properties. In particular, the methodToLongDateString()changes the selected date to a string that spells out the day and month—a long date string.C# BasCal.aspx.csusing System;public partial class BaseCal : System.Web.UI.Page{private string genString;}protected void UserChange(object sender, EventArgs e){genString=Calendar1.SelectedDate.ToLongDateString();Label1.Text = "You have selected: " + genString;}Once you’ve <strong>com</strong>pleted setting up the calendar, test it. Figure 10-2 shows the output.As you can see in Figure 10-2, the current date is March 4, and as soon as March 7 wasselected, the Label control beneath the Calendar displayed a simple message using theCalendar’s selected date in a long format as the data source.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!