Prev | Current Page 499 | Next

Rob Cameron and Dale Michalk

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

DownButtonClick);
Controls.Add(downButton);
}
}
}
392 CHAPTER 8 ?–  I NTEGRAT ING CLI ENT-SI D E SCRIPT
Listing 8-12. The UpDown JavaScript File
function __UpDown_Check(boxid, min, max)
{
var box = document.getElementById(boxid);
if (isNaN(parseInt(box.value)))
box.value = min;
if (box.value > max)
{
alert('Value cannot be greater than the Maximum allowed.');
box.value = max;
}
if (box.value < min)
{
alert('Value cannot be less than the Minimum.');
box.value = min;
}
}
function __UpDown_Up(boxid, min, max, howmuch)
{
var box = document.getElementById(boxid);
var newvalue = parseInt(box.value) + howmuch;
if ((newvalue <= max) && (newvalue >= min))
box.value = newvalue;
}
function __UpDown_Down(boxid, min, max, howmuch)
{
var box = document.getElementById(boxid);
var newvalue = parseInt(box.value) - howmuch;
if ((newvalue <= max) && (newvalue >= min))
box.value = newvalue;
}
In the next section, we move on to the web form demonstration of our newly minted
UpDown custom server control, testing that it correctly implements the expected UI logic.
The UpDown Web Form
To test the UpDown control, we place it on a web form named UpDown and take it for a test drive,
as shown in Figure 8-9. Clicking the buttons shows that the time label isn??™t advancing.


Pages:
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511