Prev | Current Page 520 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadSymbols();
}
}
private void LoadSymbols()
{
stockNews.DataSource = new string[] { "MSFT", "IBM", "GOOG", "ORCL" };
stockNews.DataBind();
}
}
}
Summary
Client-side scripts can make a web application more appealing, interactive, and scalable. ASP.NET
allows encapsulation of the client-side script code to reduce some of the inherent complexity
client script can bring to web development projects. Controls support adding client-side event
attributes to the .aspx page declaratively and programmatically via the Attributes collection.
Also, the ClientScriptManager class that is tied to the Page.ClientScript property supports
several options for registering client-side scripts: RegisterClientScriptBlock for the top of the
form, RegisterStartupScript for the bottom of the form, RegisterArrayDeclaration for adding
an array, and RegisterOnSubmitStatement for hooking into the onsubmit event of the form.
Client-side detection is done through an instance of the HttpBrowserCapabilities class.
An instance is provided by the Page.Request.Browser class. Controls should provide graceful
degradation wherever possible, in case a client doesn??™t support client-side functionality to the
level required.


Pages:
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532