Prev | Current Page 487 | Next

Rob Cameron and Dale Michalk

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

ClientScript.RegisterClientScriptResource(typeof(UpDown),
"ControlsBook2Lib.Ch08.UpDown.js");
}
}
First, we add a script to the valueTextBox TextBox to check its value when the user tabs out
or otherwise exits the control. The onblur client-side event is triggered anytime a user enters a
value in the text box and switches the focus from that element on the web page to some other
element. The CHECK_FUNC constant points to __UpDown_Check in UpDown.js. Here is the code for
__UpDown_Check:
function __UpDown_Check(boxid, min, max)
{
var box = document.getElementById(boxid);
if (isNaN(parseInt(box.value)))
box.value = min;
if (box.value > max)
box.value = max;
if (box.value < min)
box.value = min;
}
We have to pass in the exact ID of the control on the client side, as well as our minimum
and maximum values for validation purposes. The client script checks for nonnumeric values
and resets to the minimum value if they are found. The next part of OnPreRender configures
client-side script for the plus and minus buttons:
// add the '+' button client script function that
// manipulates the textbox on the client side
if (renderClientScript)
{
scriptInvoke = UP_FUNC + "('" + valueTextBox.UniqueID +
"'," + this.MinValue + "," + this.


Pages:
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499