Prev | Current Page 492 | Next

Rob Cameron and Dale Michalk

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

UniqueID];
int postedNumber = 0;
try
{
postedNumber = System.Int32.Parse(postedValue);
if (!Value.Equals(postedNumber))
changed = true;
Value = postedNumber;
}
catch (FormatException fe)
{
changed = false;
}
return changed;
}
384 CHAPTER 8 ?–  I NTEGRAT ING CLI ENT-SI D E SCRIPT
If the value is an integer, we can assign it to the Value property. We perform range checking
in the property declaration. Before we do assign the value, we first check the Value property??™s
ViewState value to see if there was indeed a change. If this is the case, we return true from the
function. Returning true causes RaisePostChangedEvent to be invoked and, in turn, raise our
ValueChanged event via the OnValueChanged helper method, as shown in the following code:
void IPostBackDataHandler.RaisePostDataChangedEvent()
{
OnValueChanged(EventArgs.Empty);
}
Because our control publishes just a single event, the corresponding
RaisePostDataChangedEvent is also simple. In the next section, we drill down into how child
button clicks that change the value are handled by the composite control and how the control
dynamically determines whether or not to fire server-side events.
Handling Child Control Events
We glossed over the fact that we mapped the button-click events to server-side handlers in our
composite UpDown control.


Pages:
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504