none
adding to OnChanging event partial method RRS feed

  • Question

  • I would like to add a calculation to my Rate property so that the user can entry a decimal value and the calc runs on that value setting the rate value to the calcd amt. Something like below.  But i just realized the onchanging event takes place on the load of the data or somewhere before my code changes the value  Movie.Rate = .99;   How can i accomplish this?

            partial void OnRateChanging(global::System.Decimal value)
            {

         //Set the value to 1/2

               value = value /2 ;

            }


    M~

    Thursday, July 12, 2012 12:49 PM

Answers

  • That has the same effect as on changing.  I handled it in the front end.  I dont believe the Change events are for modifying, only validating and maybe executing another method or event

    M~


    • Marked as answer by WIJ Thursday, July 12, 2012 7:04 PM
    • Edited by WIJ Thursday, July 12, 2012 7:08 PM
    Thursday, July 12, 2012 7:04 PM

All replies

  • Hi,

    you can take a look on how to use the partial methods properly at here:

    http://msdn.microsoft.com/en-us/library/cc716747(v=vs.90).aspx

    I'd move the calculation logic from the partial method to somewhere on the presentation layer.

    Or if you really have to do it in a partial method, you could do it this way:

     partial void OnRateChanged(global::System.Decimal value) // OnRateChanged instead of OnRateChanging
     { 

       Rate /= 2;

     }

    Regards,

    Giorgi


    Clarity VS Precision



    Thursday, July 12, 2012 2:39 PM
  • That has the same effect as on changing.  I handled it in the front end.  I dont believe the Change events are for modifying, only validating and maybe executing another method or event

    M~


    • Marked as answer by WIJ Thursday, July 12, 2012 7:04 PM
    • Edited by WIJ Thursday, July 12, 2012 7:08 PM
    Thursday, July 12, 2012 7:04 PM