Yes, you need to override the TextBox
's LoadPostData
method, which actually comes from implementing IPostBackDataHandler
. This happens early in the page lifecycle and actually from there the control gets its Text
property.
There, you can jump in and get the value straight from the request params.
However, since you're extending the text box you will always have the text property. A clean version would imply extending Control
and doing the input rendering yourself. You would drop the Text
property altogether and keep only your Number
property.
The code would be cleaner and a lot easier to read. But it implies a bit more work, of course. Note that in case you are extending Control
directly, you need to implement IPostBackDataHandler
. That interface basically tells the page that your control posts data back and it needs to be handled differently.