0

I developed a textbox control which shows rounded off data on blur and actual data on focus. currently this is being done using JS and value change has no relation with ASP.NET model.

Is it possible to add two properties to model and bind them to these events? ie, If I have A & B, on blur A should be bound and on focus B should be bound. And each time when user modifies B, the changed value should be reflected in A (after rounding off).

I checked many websites, but I couldn't understand any of it. Few of them are,

Community
  • 1
  • 1
Prajwal
  • 3,930
  • 5
  • 24
  • 50

1 Answers1

0

I'm assuming what you're after here is having both the rounded and actual data on post. If so, there's a better way than actually posting both. Just add a property to your view model that returns the rounded data:

public decimal Data { get; set; }

public int RoundedData
{
    get { return Convert.ToInt32(Math.Round(Data, 0)); }
}
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444