This is a migrated thread and some comments may be shown as answers.

[Solved] CurrencyTextbox

1 Answer 115 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
k
Top achievements
Rank 1
k asked on 05 Oct 2011, 03:37 PM
I've a currency textbox which is binded to model property. The model property is defined as non-nullable decimal

decimal Price { get; set; }

In my view:

 

 

@(Html.Telerik().CurrencyTextBox() 
.Name("Price") 
.Value(Model.Price)
.Spinners(false) 
)

When I am displaying the view first time, the Price textbox by default displaying $0.0. How to display empty textbox when price value is 0.0. I've tried the bewlo code which is giving me "object reference" error.

 

@ { var temp = Modle.Price == 0 ? (decimal?)null : Model.Price }

 

 

And used temp variable to set value to currency textbox.

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Eduardo
Top achievements
Rank 1
answered on 04 Nov 2011, 05:01 PM
Hi,

I solved that problem this way:

[Required]
public decimal? Price{ getset; }

that way, it's required to enter an you get 'Enter a value' in your CurrencyTextBox

Hope this helps
Tags
NumericTextBox
Asked by
k
Top achievements
Rank 1
Answers by
Eduardo
Top achievements
Rank 1
Share this question
or