SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 316 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

Furthermore, the user should be able to enter a new stock ticker in the main
CHAPTER 10 ?–  BUILDING A SAMPLE APPLICATION USING ASP.NET AJAX 234
TextBox and have the data updated. So to address these points, we need to first call the
GetCompanyInfo method during the Page_Load event and then create a Timer control. In the
control??™s Tick event handler, we call the method shown here:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetCompanyInfo(txtTicker.Text.Trim());
//Default to first tab
Update(0);
}
}
This way, the ticker information is updated in regular intervals, and if the user enters
a new stock ticker, the changes are reflected as soon as the GetCompanyInfo method is
called again (in 5 seconds).
To create a timer for this page, drag and drop the ASP.NET AJAX Timer control from
the Toolbox onto the page, and set its Interval property to 5000ms, so that the page
updates every 5 seconds. Also, don??™t forget to set the event handler for the Tick event as
shown here:
"Timer1_Tick">
Lastly, for the timer functionality to work properly, you must call the GetCompanyInfo
method in the Timer1_Tick event handler as such:
protected void Timer1_Tick(object sender, EventArgs e)
{
GetCompanyInfo(txtTicker.


Pages:
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328