Coming Up in VS 2005
Coming Up in VS 2005
0 Series
Quartz Systems
Enhancements in the CLR,
Compilers
Before
Generics
Generics
public class List<T>
public class List
{{
object[]
private T
private elements;
[] elements;
private int
private int count;
count;
public void
public void Add(
Add(object element)
T element) { {
if (count
if (count ==
== elements.Length)
elements.Length) Resize(count
Resize(count *
* 2);
2);
elements[count++] =
elements[count++] = element;
element;
}
}
public
public object
T this[int
this[int index]
index] { {
get
get {
{ return elements[index];
return elements[index]; }}
set
set {
{ elements[index] =
elements[index] = value;
value; }}
}
}
public List<int>
List
int intList
intList
Count { new List<int>();
= new=List();
public int Count {
get
get { return
{ return count;
count; }}
} intList.Add(1); // No
Argument
boxingis boxed
} intList.Add(2); // No
Argument
boxingis boxed
}
} intList.Add("Three"); // Compile-time
Should be an error
int i = intList[0];
(int)intList[0]; Cast
// No required
cast required
Generics In VB
Public Class List(Of T)
Private elements() As T
Private elementcount As Integer
Public Sub Add(ByVal element As T)
If elementcount = elements.Length Then
Resize(elementcount * 2)
elements(elementcount) = element
count += 1
End Sub
Public Default Property Item(ByVal index As Integer) As T
Get
Return elements(index)
End Get
Set (ByVal Value As T)
elements(index)
Dim intList = Value
As New List(Of Integer)
End Set
intList.Add(1) // No boxing
End Property
intList.Add(2) // No boxing
intList.Add("Three") // Compile-time error
Dim i As Integer = intList(0) // No cast required
Generics In C++
generic<typename T>
public ref class List {
array<T>^ elements;
int count;
public:
void Add(T element) {
if (count == elements->Length) Resize(count * 2);
elements[count++] = element;
}
property T default [int index] {
T get() { return elements[index]; }
void set(T value) { elements[index] = value; }
}
property int Count {
intList<int>^ intList
get() { return = gcnew
count; } List<int>();
} intList->Add(1); // No boxing
}; intList->Add(2); // No boxing
intList->Add("Three"); // Compile-time error
int i = intList[0]; // No cast required
Generics
Why generics?
Type checking, no boxing, no downcasts
Reduced code bloat (typed collections)
public MyForm() {
listBox = new ListBox(...);
textBox = new TextBox(...);
addButton = new Button(...);
addButton.Click += delegate
new EventHandler(AddClick);
{
} listBox.Items.Add(textBox.Text);
};
}void AddClick(object sender, EventArgs e) {
} listBox.Items.Add(textBox.Text);
}
}
Anonymous Methods
Allows code block in place of delegate
Delegate type automatically inferred
Code block can be parameterless
Or code block can have parameters
In either case, return types must match
using System;
using System.Threading;
class Program
{
static void Work() {…}
Content
Footer
Web Sites Today
Header
Navigation
Content
Footer
Current Web Approaches
User Controls
Include File
Anything else that you can dream
of……….
Current Web Approaches
User Controls and Include Files
<asp:ContentPlaceHolder
Id=MainContent />
Footer
How Master Pages Work
Runtime
http://serverName/SiteName/Default.aspx
Header
Navigation
Footer
MySite.master
Creating A Master Page
<%@ master language="VB"%>
<html>
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<table>
<tr ><td><h1><!-- Header goes here --></h1></td></tr>
<tr> <td><h2><!-- Navigation goes here --></h2></td></tr>
<tr><td>
<!-- Content Place holder without default content -->
<asp:contentplaceholder id=“LeftSideContent" runat="server“/>
</td>
<td>
<!-- Content Place holder withdefault content -->
<asp:contentplaceholder id=“rightSideContent" runat="server">
<asp:label runat=Server id=foo>Default content!!!</asp:label>
</asp:contentplaceholder>
</td></tr></table>
</form>
</body>
</html>
MySite.master
How To Use A Master Page
1. Create an ASP.NET page
2. Add the master attribute to the
page directive
<%@ page master= %>
3. Add content for the master place
holder regions
Use the <asp:content ..> control
The ContentPlaceHolderId define the place holder region
to redefine
Can contain any page content
Master Page
Device Specific
Mechanism to override the master page based
on the requesting device
Improve the end user experience
<%@ page language="VB" master="~/Mysite.master"
ie:master=“~/MysiteIE.master”
Longhorn:master=“~/MysiteLonghorn.master”
Mozilla:master=“~/MysiteMozilla.master” %>
Default.aspx
Master Page
Nested Master
Enable developers a way to define a Master
page for a master
Useful when site enforces a layout but allow
site section with a nested to define sub-layouts
Master Pages
Nested Master
Site.Master
Master Pages
Nested Master
DevelopmentTools.Master
Master Pages
Nested Master
Partners.aspx HowToBuy.aspx
Master Page
Programmability
Page can access the master page
Page.Master property
Can access public properties in Master
FindControl to access controls
Page can set its master page dynamically
Page.MasterFilePath property (Beta 1)
Dynamically set Master from the page
Ex. Co branding of the site
Will be available in Beta timeframe
Master Page
Configuration
Page level configuration
<%@ master language="VB“ master="~/Mysite.master" %>
LabelControlSkins.Skins
Using Theme And Skin
1. On the page
Define a reference to the theme
Note: Links are page relative
2. On a control
Define nothing. If a default control skin exists it
will be picked up
Define the skinid on the control; will utilize the
named skin
3. Prevent themeing by:
EnableThemeing=false on page or control
All child controls inherit the parent setting
Using Theme And Skin
<%@ Page language="VB“ theme=“BabyBoy”%>
<html><head runat="server"></head><body><form id="form1" runat="server">
<table>
<tr ><td><h1><asp:label runat=Server skinid=Title id=foo text=Default /></td></tr>
/>
<tr> <td><h2><!-- Navigation goes here --></h2></td></tr>
<tr><td>
<!-- Content Place holder without default content -->
<asp:contentplaceholder id=“LeftSideContent" runat="server“/>
</td>
<td>
<!-- Content Place holder withdefault content -->
<asp:contentplaceholder id=“RightSideContent" runat="server">
<asp:label runat=Server id=foo>Default content!!!</asp:label>
</asp:contentplaceholder>
</td></tr></table>
</form>
</body>
</html>
Default.aspx
Themes
Configuration
Page level configuration
<%@ master language="VB“ theme=“BasicBlue" %>