Web Control - Convert Input Value From String To Decimal [VB.Net]

Discussion in 'ASP .Net Web Controls' started by Mythran, Aug 10, 2005.

  1. Mythran

    Mythran Guest

    My WebControl inherits from WebControl and implements IPostBackDataHandler
    and IValidator.

    The WebControl has quite a few properties associated with it. The primary,
    default property is "Value" of type Decimal.

    In the implemented LoadPostData method for the IPostBackDataHandler
    interface, I store the String value that was submitted by the postback.
    This value is stored in a private member variable. I can't directly assign
    the String value to the Value property because the String value may not be
    valid, this is why I store it in a member variable. When Validate() is
    called (for the IValidator implementation), I then validate the stored
    String value and set IsValid to True or False based on whether the string
    value is valid. If it is valid, I also update the Value property of the
    WebControl to the proper value. I also have an AutoPostBack Boolean propery
    on this control. When True, the client will automatically post back to the
    server when the value is changed.

    So, my problem:

    I place my WebControl onto a form, place a button on the form with
    CausesValidation set to True. When I click on the button, the validation
    occurs correctly and my validation is performed and the Value is updated to
    the correct value (if valid). When I set AutoPostBack to True on my
    WebControl, the WebControl posts back to the server correctly, but
    Validation does NOT fire. How can I force validation to fire so the Value
    property will be updated?

    I only want validation to occur if Page.Validate() or
    MyWebControl.Validate() has been called, or if the user entered a new value
    and AutoPostBack is set to True. I do not, for example, wnat the validation
    to occur if the value is changed from the server (via code-behind).

    Anyone have a clue what I just asked and have a suggestion?

    Thanks,
    Mythran
     
    Mythran, Aug 10, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Golan
    Replies:
    7
    Views:
    2,170
    Malcolm
    Dec 8, 2003
  2. Julian Hernandez Gomez

    convert user input to Decimal objects using eval()?

    Julian Hernandez Gomez, Mar 28, 2005, in forum: Python
    Replies:
    4
    Views:
    450
    Raymond Hettinger
    Mar 30, 2005
  3. Swaroop C H
    Replies:
    0
    Views:
    578
    Swaroop C H
    Mar 28, 2005
  4. Vitaliy
    Replies:
    1
    Views:
    497
    Peter Otten
    May 29, 2008
  5. valpa
    Replies:
    11
    Views:
    1,586
    Steven D'Aprano
    Mar 24, 2009
Loading...

Share This Page